@odoo/o-spreadsheet 18.4.23 → 18.4.25

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.23
6
- * @date 2026-01-07T16:21:07.502Z
7
- * @hash a0135e8
5
+ * @version 18.4.25
6
+ * @date 2026-01-21T11:06:11.131Z
7
+ * @hash 161472d
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -41,7 +41,8 @@
41
41
  return children
42
42
  .map((child) => (typeof child === "function" ? child(env) : child))
43
43
  .flat()
44
- .map(createAction);
44
+ .map(createAction)
45
+ .sort((a, b) => a.sequence - b.sequence);
45
46
  }
46
47
  : () => [],
47
48
  isReadonlyAllowed: item.isReadonlyAllowed || false,
@@ -333,6 +334,7 @@
333
334
  fillColor: "",
334
335
  textColor: "",
335
336
  };
337
+ const DEFAULT_NUMBER_STYLE = { ...DEFAULT_STYLE, align: "right" };
336
338
  const DEFAULT_VERTICAL_ALIGN = DEFAULT_STYLE.verticalAlign;
337
339
  const DEFAULT_WRAPPING_MODE = DEFAULT_STYLE.wrapping;
338
340
  // Fonts
@@ -6386,67 +6388,6 @@
6386
6388
  return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
6387
6389
  }
6388
6390
 
6389
- function createDefaultRows(rowNumber) {
6390
- const rows = [];
6391
- for (let i = 0; i < rowNumber; i++) {
6392
- const row = {
6393
- cells: {},
6394
- };
6395
- rows.push(row);
6396
- }
6397
- return rows;
6398
- }
6399
- function moveHeaderIndexesOnHeaderAddition(indexHeaderAdded, numberAdded, headers) {
6400
- return headers.map((header) => {
6401
- if (header >= indexHeaderAdded) {
6402
- return header + numberAdded;
6403
- }
6404
- return header;
6405
- });
6406
- }
6407
- function moveHeaderIndexesOnHeaderDeletion(deletedHeaders, headers) {
6408
- deletedHeaders = [...deletedHeaders].sort((a, b) => b - a);
6409
- return headers
6410
- .map((header) => {
6411
- for (const deletedHeader of deletedHeaders) {
6412
- if (header > deletedHeader) {
6413
- header--;
6414
- }
6415
- else if (header === deletedHeader) {
6416
- return undefined;
6417
- }
6418
- }
6419
- return header;
6420
- })
6421
- .filter(isDefined);
6422
- }
6423
- function getNextSheetName(existingNames, baseName = "Sheet") {
6424
- let i = 1;
6425
- let name = `${baseName}${i}`;
6426
- while (existingNames.includes(name)) {
6427
- name = `${baseName}${i}`;
6428
- i++;
6429
- }
6430
- return name;
6431
- }
6432
- function getDuplicateSheetName(nameToDuplicate, existingNames) {
6433
- let i = 1;
6434
- const baseName = _t("Copy of %s", nameToDuplicate);
6435
- let name = baseName.toString();
6436
- while (existingNames.includes(name)) {
6437
- name = `${baseName} (${i})`;
6438
- i++;
6439
- }
6440
- return name;
6441
- }
6442
- function isSheetNameEqual(name1, name2) {
6443
- if (name1 === undefined || name2 === undefined) {
6444
- return false;
6445
- }
6446
- return (getUnquotedSheetName(name1.trim().toUpperCase()) ===
6447
- getUnquotedSheetName(name2.trim().toUpperCase()));
6448
- }
6449
-
6450
6391
  function createRange(args, getSheetSize) {
6451
6392
  const unboundedZone = args.zone;
6452
6393
  const zone = boundUnboundedZone(unboundedZone, getSheetSize(args.sheetId));
@@ -6690,8 +6631,8 @@
6690
6631
  elements.sort((a, b) => b - a);
6691
6632
  const groups = groupConsecutive(elements);
6692
6633
  return (range) => {
6693
- if (!isSheetNameEqual(range.sheetId, cmd.sheetId)) {
6694
- return { changeType: "NONE" };
6634
+ if (range.sheetId !== cmd.sheetId) {
6635
+ return { changeType: "NONE", range };
6695
6636
  }
6696
6637
  let newRange = range;
6697
6638
  let changeType = "NONE";
@@ -6718,10 +6659,7 @@
6718
6659
  newRange = createAdaptedRange(newRange, dimension, changeType, -(max - min + 1));
6719
6660
  }
6720
6661
  }
6721
- if (changeType !== "NONE") {
6722
- return { changeType, range: newRange };
6723
- }
6724
- return { changeType: "NONE" };
6662
+ return { changeType, range: newRange };
6725
6663
  };
6726
6664
  }
6727
6665
  function getApplyRangeChangeAddColRow(cmd) {
@@ -6730,7 +6668,7 @@
6730
6668
  const dimension = cmd.dimension === "COL" ? "columns" : "rows";
6731
6669
  return (range) => {
6732
6670
  if (range.sheetId !== cmd.sheetId) {
6733
- return { changeType: "NONE" };
6671
+ return { changeType: "NONE", range };
6734
6672
  }
6735
6673
  if (cmd.position === "after") {
6736
6674
  if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) {
@@ -6760,13 +6698,13 @@
6760
6698
  };
6761
6699
  }
6762
6700
  }
6763
- return { changeType: "NONE" };
6701
+ return { changeType: "NONE", range };
6764
6702
  };
6765
6703
  }
6766
6704
  function getApplyRangeChangeDeleteSheet(cmd) {
6767
6705
  return (range) => {
6768
6706
  if (range.sheetId !== cmd.sheetId && range.invalidSheetName !== cmd.sheetName) {
6769
- return { changeType: "NONE" };
6707
+ return { changeType: "NONE", range };
6770
6708
  }
6771
6709
  const invalidSheetName = cmd.sheetName;
6772
6710
  range = {
@@ -6793,14 +6731,14 @@
6793
6731
  const newRange = { ...range, sheetId, invalidSheetName };
6794
6732
  return { changeType: "CHANGE", range: newRange };
6795
6733
  }
6796
- return { changeType: "NONE" };
6734
+ return { changeType: "NONE", range };
6797
6735
  };
6798
6736
  }
6799
6737
  function getApplyRangeChangeMoveRange(cmd) {
6800
6738
  const originZone = cmd.target[0];
6801
6739
  return (range) => {
6802
6740
  if (range.sheetId !== cmd.sheetId || !isZoneInside(range.zone, originZone)) {
6803
- return { changeType: "NONE" };
6741
+ return { changeType: "NONE", range };
6804
6742
  }
6805
6743
  const targetSheetId = cmd.targetSheetId;
6806
6744
  const offsetX = cmd.col - originZone.left;
@@ -6897,17 +6835,87 @@
6897
6835
  return results.map((r) => r.elem);
6898
6836
  }
6899
6837
 
6838
+ function createDefaultRows(rowNumber) {
6839
+ const rows = [];
6840
+ for (let i = 0; i < rowNumber; i++) {
6841
+ const row = {
6842
+ cells: {},
6843
+ };
6844
+ rows.push(row);
6845
+ }
6846
+ return rows;
6847
+ }
6848
+ function moveHeaderIndexesOnHeaderAddition(indexHeaderAdded, numberAdded, headers) {
6849
+ return headers.map((header) => {
6850
+ if (header >= indexHeaderAdded) {
6851
+ return header + numberAdded;
6852
+ }
6853
+ return header;
6854
+ });
6855
+ }
6856
+ function moveHeaderIndexesOnHeaderDeletion(deletedHeaders, headers) {
6857
+ deletedHeaders = [...deletedHeaders].sort((a, b) => b - a);
6858
+ return headers
6859
+ .map((header) => {
6860
+ for (const deletedHeader of deletedHeaders) {
6861
+ if (header > deletedHeader) {
6862
+ header--;
6863
+ }
6864
+ else if (header === deletedHeader) {
6865
+ return undefined;
6866
+ }
6867
+ }
6868
+ return header;
6869
+ })
6870
+ .filter(isDefined);
6871
+ }
6872
+ function getNextSheetName(existingNames, baseName = "Sheet") {
6873
+ let i = 1;
6874
+ let name = `${baseName}${i}`;
6875
+ while (existingNames.includes(name)) {
6876
+ name = `${baseName}${i}`;
6877
+ i++;
6878
+ }
6879
+ return name;
6880
+ }
6881
+ function getDuplicateSheetName(nameToDuplicate, existingNames) {
6882
+ let i = 1;
6883
+ const baseName = _t("Copy of %s", nameToDuplicate);
6884
+ let name = baseName.toString();
6885
+ while (existingNames.includes(name)) {
6886
+ name = `${baseName} (${i})`;
6887
+ i++;
6888
+ }
6889
+ return name;
6890
+ }
6891
+ function isSheetNameEqual(name1, name2) {
6892
+ if (name1 === undefined || name2 === undefined) {
6893
+ return false;
6894
+ }
6895
+ return (getUnquotedSheetName(name1.trim().toUpperCase()) ===
6896
+ getUnquotedSheetName(name2.trim().toUpperCase()));
6897
+ }
6898
+
6900
6899
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
6901
6900
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
6902
6901
  }
6903
6902
  /**
6904
6903
  * Get the default height of the cell given its style.
6905
6904
  */
6906
- function getDefaultCellHeight(ctx, cell, colSize) {
6905
+ function getDefaultCellHeight(ctx, cell, locale, colSize) {
6907
6906
  if (!cell || (!cell.isFormula && !cell.content)) {
6908
6907
  return DEFAULT_CELL_HEIGHT;
6909
6908
  }
6910
- const content = cell.isFormula ? "" : cell.content;
6909
+ let content = "";
6910
+ try {
6911
+ if (!cell.isFormula) {
6912
+ const localeFormat = { format: cell.format, locale };
6913
+ content = formatValue(parseLiteral(cell.content, locale), localeFormat);
6914
+ }
6915
+ }
6916
+ catch {
6917
+ content = CellErrorType.GenericError;
6918
+ }
6911
6919
  return getCellContentHeight(ctx, content, cell.style, colSize);
6912
6920
  }
6913
6921
  function getCellContentHeight(ctx, content, style, colSize) {
@@ -19069,9 +19077,10 @@ stores.inject(MyMetaStore, storeInstance);
19069
19077
  throw new EvaluationError(_t("Function PIVOT takes an even number of arguments."));
19070
19078
  }
19071
19079
  }
19072
- function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
19080
+ function addPivotDependencies(evalContext, pivotId, forMeasures) {
19073
19081
  //TODO This function can be very costly when used with PIVOT.VALUE and PIVOT.HEADER
19074
19082
  const dependencies = [];
19083
+ const coreDefinition = evalContext.getters.getPivotCoreDefinition(pivotId);
19075
19084
  if (coreDefinition.type === "SPREADSHEET" && coreDefinition.dataSet) {
19076
19085
  const { sheetId, zone } = coreDefinition.dataSet;
19077
19086
  const xc = zoneToXc(zone);
@@ -19088,8 +19097,7 @@ stores.inject(MyMetaStore, storeInstance);
19088
19097
  }
19089
19098
  for (const measure of forMeasures) {
19090
19099
  if (measure.computedBy) {
19091
- const formula = evalContext.getters.getMeasureCompiledFormula(measure);
19092
- dependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
19100
+ dependencies.push(...evalContext.getters.getMeasureFullDependencies(pivotId, measure));
19093
19101
  }
19094
19102
  }
19095
19103
  const originPosition = evalContext.__originCellPosition;
@@ -19558,7 +19566,7 @@ stores.inject(MyMetaStore, storeInstance);
19558
19566
  assertDomainLength(domainArgs);
19559
19567
  const pivot = this.getters.getPivot(pivotId);
19560
19568
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
19561
- addPivotDependencies(this, coreDefinition, coreDefinition.measures.filter((m) => m.id === _measure));
19569
+ addPivotDependencies(this, pivotId, coreDefinition.measures.filter((m) => m.id === _measure));
19562
19570
  pivot.init({ reload: pivot.needsReevaluation });
19563
19571
  const error = pivot.assertIsValid({ throwOnError: false });
19564
19572
  if (error) {
@@ -19591,8 +19599,7 @@ stores.inject(MyMetaStore, storeInstance);
19591
19599
  const _pivotId = getPivotId(_pivotFormulaId, this.getters);
19592
19600
  assertDomainLength(domainArgs);
19593
19601
  const pivot = this.getters.getPivot(_pivotId);
19594
- const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
19595
- addPivotDependencies(this, coreDefinition, []);
19602
+ addPivotDependencies(this, _pivotId, []);
19596
19603
  pivot.init({ reload: pivot.needsReevaluation });
19597
19604
  const error = pivot.assertIsValid({ throwOnError: false });
19598
19605
  if (error) {
@@ -19650,7 +19657,7 @@ stores.inject(MyMetaStore, storeInstance);
19650
19657
  const pivotId = getPivotId(_pivotFormulaId, this.getters);
19651
19658
  const pivot = this.getters.getPivot(pivotId);
19652
19659
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
19653
- addPivotDependencies(this, coreDefinition, coreDefinition.measures);
19660
+ addPivotDependencies(this, pivotId, coreDefinition.measures);
19654
19661
  pivot.init({ reload: pivot.needsReevaluation });
19655
19662
  const error = pivot.assertIsValid({ throwOnError: false });
19656
19663
  if (error) {
@@ -20989,7 +20996,16 @@ stores.inject(MyMetaStore, storeInstance);
20989
20996
  }
20990
20997
  acceptToVectorize.push(!argDefinition.acceptMatrix);
20991
20998
  }
20992
- return applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize);
20999
+ return replaceErrorPlaceholderInResult(applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize));
21000
+ }
21001
+ function replaceErrorPlaceholderInResult(result) {
21002
+ if (!isMatrix(result)) {
21003
+ replaceFunctionNamePlaceholder(result, descr.name);
21004
+ }
21005
+ else {
21006
+ matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
21007
+ }
21008
+ return result;
20993
21009
  }
20994
21010
  function errorHandlingCompute(...args) {
20995
21011
  for (let i = 0; i < args.length; i++) {
@@ -21018,13 +21034,12 @@ stores.inject(MyMetaStore, storeInstance);
21018
21034
  const result = descr.compute.apply(this, args);
21019
21035
  if (!isMatrix(result)) {
21020
21036
  if (typeof result === "object" && result !== null && "value" in result) {
21021
- replaceFunctionNamePlaceholder(result, descr.name);
21022
21037
  return result;
21023
21038
  }
21039
+ descr.name;
21024
21040
  return { value: result };
21025
21041
  }
21026
21042
  if (typeof result[0][0] === "object" && result[0][0] !== null && "value" in result[0][0]) {
21027
- matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
21028
21043
  return result;
21029
21044
  }
21030
21045
  return matrixMap(result, (row) => ({ value: row }));
@@ -21476,7 +21491,7 @@ stores.inject(MyMetaStore, storeInstance);
21476
21491
  continue;
21477
21492
  }
21478
21493
  const sheetXC = tokens[tokenIdx].value;
21479
- const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange);
21494
+ const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange).range;
21480
21495
  if (sheetXC !== newSheetXC) {
21481
21496
  tokens[tokenIdx] = {
21482
21497
  value: newSheetXC,
@@ -21486,23 +21501,30 @@ stores.inject(MyMetaStore, storeInstance);
21486
21501
  }
21487
21502
  return concat(tokens.map((token) => token.value));
21488
21503
  }
21489
- function adaptStringRange(defaultSheetId, sheetXC, applyChange) {
21504
+ function adaptStringRange(defaultSheetId, sheetXC, rangeAdapter) {
21490
21505
  const sheetName = splitReference(sheetXC).sheetName;
21491
21506
  if (sheetName
21492
- ? !isSheetNameEqual(sheetName, applyChange.sheetName.old)
21493
- : defaultSheetId !== applyChange.sheetId) {
21494
- return sheetXC;
21507
+ ? !isSheetNameEqual(sheetName, rangeAdapter.sheetName.old)
21508
+ : defaultSheetId !== rangeAdapter.sheetId) {
21509
+ return { changeType: "NONE", range: sheetXC };
21495
21510
  }
21496
- const sheetId = sheetName ? applyChange.sheetId : defaultSheetId;
21511
+ const sheetId = sheetName ? rangeAdapter.sheetId : defaultSheetId;
21497
21512
  const range = getRange(sheetXC, sheetId);
21498
21513
  if (range.invalidXc) {
21499
- return sheetXC;
21514
+ return { changeType: "NONE", range: sheetXC };
21500
21515
  }
21501
- const change = applyChange.applyChange(range);
21516
+ const change = rangeAdapter.applyChange(range);
21502
21517
  if (change.changeType === "NONE" || change.changeType === "REMOVE") {
21503
- return sheetXC;
21518
+ return { changeType: change.changeType, range: sheetXC };
21519
+ }
21520
+ const rangeStr = getRangeString(change.range, defaultSheetId, getSheetNameGetter(rangeAdapter));
21521
+ if (rangeStr === CellErrorType.InvalidReference) {
21522
+ return { changeType: "REMOVE", range: rangeStr };
21504
21523
  }
21505
- return getRangeString(change.range, defaultSheetId, getSheetNameGetter(applyChange));
21524
+ return {
21525
+ changeType: change.changeType,
21526
+ range: rangeStr,
21527
+ };
21506
21528
  }
21507
21529
  function getSheetNameGetter(applyChange) {
21508
21530
  return (sheetId) => {
@@ -21607,8 +21629,6 @@ stores.inject(MyMetaStore, storeInstance);
21607
21629
  }
21608
21630
  const change = applyChange(range);
21609
21631
  switch (change.changeType) {
21610
- case "NONE":
21611
- return range;
21612
21632
  case "REMOVE":
21613
21633
  return undefined;
21614
21634
  default:
@@ -21760,16 +21780,16 @@ stores.inject(MyMetaStore, storeInstance);
21760
21780
  function transformChartDefinitionWithDataSetsWithZone(chartSheetId, definition, applyChange) {
21761
21781
  let labelRange;
21762
21782
  if (definition.labelRange) {
21763
- const adaptedRange = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
21764
- if (adaptedRange !== CellErrorType.InvalidReference) {
21783
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
21784
+ if (changeType !== "REMOVE") {
21765
21785
  labelRange = adaptedRange;
21766
21786
  }
21767
21787
  }
21768
21788
  const dataSets = [];
21769
21789
  for (const dataSet of definition.dataSets) {
21770
21790
  const newDataSet = { ...dataSet };
21771
- const adaptedRange = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
21772
- if (adaptedRange !== CellErrorType.InvalidReference) {
21791
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
21792
+ if (changeType !== "REMOVE") {
21773
21793
  newDataSet.dataRange = adaptedRange;
21774
21794
  dataSets.push(newDataSet);
21775
21795
  }
@@ -23147,14 +23167,14 @@ stores.inject(MyMetaStore, storeInstance);
23147
23167
  let baseline;
23148
23168
  let keyValue;
23149
23169
  if (definition.baseline) {
23150
- const adaptedRange = adaptStringRange(chartSheetId, definition.baseline, applyChange);
23151
- if (adaptedRange !== CellErrorType.InvalidReference) {
23170
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.baseline, applyChange);
23171
+ if (changeType !== "REMOVE") {
23152
23172
  baseline = adaptedRange;
23153
23173
  }
23154
23174
  }
23155
23175
  if (definition.keyValue) {
23156
- const adaptedRange = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
23157
- if (adaptedRange !== CellErrorType.InvalidReference) {
23176
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
23177
+ if (changeType !== "REMOVE") {
23158
23178
  keyValue = adaptedRange;
23159
23179
  }
23160
23180
  }
@@ -23211,7 +23231,7 @@ stores.inject(MyMetaStore, storeInstance);
23211
23231
  // This kind of graph is not exportable in Excel
23212
23232
  return undefined;
23213
23233
  }
23214
- updateRanges(applyChange) {
23234
+ updateRanges({ applyChange }) {
23215
23235
  const baseline = adaptChartRange(this.baseline, applyChange);
23216
23236
  const keyValue = adaptChartRange(this.keyValue, applyChange);
23217
23237
  if (this.baseline === baseline && this.keyValue === keyValue) {
@@ -26585,7 +26605,7 @@ stores.inject(MyMetaStore, storeInstance);
26585
26605
  verticalAxis: getDefinedAxis(definition),
26586
26606
  };
26587
26607
  }
26588
- updateRanges(applyChange) {
26608
+ updateRanges({ applyChange }) {
26589
26609
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
26590
26610
  if (!isStale) {
26591
26611
  return this;
@@ -27172,7 +27192,7 @@ stores.inject(MyMetaStore, storeInstance);
27172
27192
  verticalAxis: getDefinedAxis(definition),
27173
27193
  };
27174
27194
  }
27175
- updateRanges(applyChange) {
27195
+ updateRanges({ applyChange }) {
27176
27196
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27177
27197
  if (!isStale) {
27178
27198
  return this;
@@ -27344,7 +27364,7 @@ stores.inject(MyMetaStore, storeInstance);
27344
27364
  getDefinitionForExcel() {
27345
27365
  return undefined;
27346
27366
  }
27347
- updateRanges(applyChange) {
27367
+ updateRanges({ applyChange }) {
27348
27368
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27349
27369
  if (!isStale) {
27350
27370
  return this;
@@ -27455,8 +27475,8 @@ stores.inject(MyMetaStore, storeInstance);
27455
27475
  static transformDefinition(chartSheetId, definition, applyChange) {
27456
27476
  let dataRange;
27457
27477
  if (definition.dataRange) {
27458
- const adaptedRange = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
27459
- if (adaptedRange !== CellErrorType.InvalidReference) {
27478
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
27479
+ if (changeType !== "REMOVE") {
27460
27480
  dataRange = adaptedRange;
27461
27481
  }
27462
27482
  }
@@ -27531,13 +27551,9 @@ stores.inject(MyMetaStore, storeInstance);
27531
27551
  : undefined,
27532
27552
  };
27533
27553
  }
27534
- updateRanges(applyChange, sheetId, adaptSheetName) {
27554
+ updateRanges({ applyChange, adaptFormulaString }) {
27535
27555
  const dataRange = adaptChartRange(this.dataRange, applyChange);
27536
- const adaptFormula = (formula) => adaptFormulaStringRanges(this.sheetId, formula, {
27537
- applyChange,
27538
- sheetId,
27539
- sheetName: adaptSheetName,
27540
- });
27556
+ const adaptFormula = (formula) => adaptFormulaString(this.sheetId, formula);
27541
27557
  const sectionRule = adaptSectionRuleFormulas(this.sectionRule, adaptFormula);
27542
27558
  const definition = this.getDefinitionWithSpecificRanges(dataRange, sectionRule);
27543
27559
  return new GaugeChart(definition, this.sheetId, this.getters);
@@ -27759,7 +27775,7 @@ stores.inject(MyMetaStore, storeInstance);
27759
27775
  getDefinitionForExcel() {
27760
27776
  return undefined;
27761
27777
  }
27762
- updateRanges(applyChange) {
27778
+ updateRanges({ applyChange }) {
27763
27779
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27764
27780
  if (!isStale) {
27765
27781
  return this;
@@ -27895,7 +27911,7 @@ stores.inject(MyMetaStore, storeInstance);
27895
27911
  : undefined,
27896
27912
  };
27897
27913
  }
27898
- updateRanges(applyChange) {
27914
+ updateRanges({ applyChange }) {
27899
27915
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27900
27916
  if (!isStale) {
27901
27917
  return this;
@@ -28055,7 +28071,7 @@ stores.inject(MyMetaStore, storeInstance);
28055
28071
  labelRange,
28056
28072
  };
28057
28073
  }
28058
- updateRanges(applyChange) {
28074
+ updateRanges({ applyChange }) {
28059
28075
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28060
28076
  if (!isStale) {
28061
28077
  return this;
@@ -28194,7 +28210,7 @@ stores.inject(MyMetaStore, storeInstance);
28194
28210
  getDefinitionForExcel() {
28195
28211
  return undefined;
28196
28212
  }
28197
- updateRanges(applyChange) {
28213
+ updateRanges({ applyChange }) {
28198
28214
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28199
28215
  if (!isStale) {
28200
28216
  return this;
@@ -28345,7 +28361,7 @@ stores.inject(MyMetaStore, storeInstance);
28345
28361
  labelRange,
28346
28362
  };
28347
28363
  }
28348
- updateRanges(applyChange) {
28364
+ updateRanges({ applyChange }) {
28349
28365
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28350
28366
  if (!isStale) {
28351
28367
  return this;
@@ -28467,7 +28483,7 @@ stores.inject(MyMetaStore, storeInstance);
28467
28483
  : undefined,
28468
28484
  };
28469
28485
  }
28470
- updateRanges(applyChange) {
28486
+ updateRanges({ applyChange }) {
28471
28487
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28472
28488
  if (!isStale) {
28473
28489
  return this;
@@ -28632,7 +28648,7 @@ stores.inject(MyMetaStore, storeInstance);
28632
28648
  getDefinitionForExcel() {
28633
28649
  return undefined;
28634
28650
  }
28635
- updateRanges(applyChange) {
28651
+ updateRanges({ applyChange }) {
28636
28652
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28637
28653
  if (!isStale) {
28638
28654
  return this;
@@ -28780,7 +28796,7 @@ stores.inject(MyMetaStore, storeInstance);
28780
28796
  getDefinitionForExcel() {
28781
28797
  return undefined;
28782
28798
  }
28783
- updateRanges(applyChange) {
28799
+ updateRanges({ applyChange }) {
28784
28800
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28785
28801
  if (!isStale) {
28786
28802
  return this;
@@ -28935,7 +28951,7 @@ stores.inject(MyMetaStore, storeInstance);
28935
28951
  // TODO: implement export excel
28936
28952
  return undefined;
28937
28953
  }
28938
- updateRanges(applyChange) {
28954
+ updateRanges({ applyChange }) {
28939
28955
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28940
28956
  if (!isStale) {
28941
28957
  return this;
@@ -32643,7 +32659,6 @@ stores.inject(MyMetaStore, storeInstance);
32643
32659
  });
32644
32660
  }
32645
32661
  handleEvent(event) {
32646
- this.hideHelp();
32647
32662
  const sheetId = this.getters.getActiveSheetId();
32648
32663
  let unboundedZone;
32649
32664
  if (event.options.unbounded) {
@@ -32904,7 +32919,7 @@ stores.inject(MyMetaStore, storeInstance);
32904
32919
  }
32905
32920
  captureSelection(zone, col, row) {
32906
32921
  this.model.selection.capture(this, {
32907
- cell: { col: col ?? zone.left, row: row ?? zone.right },
32922
+ cell: { col: col ?? zone.left, row: row ?? zone.top },
32908
32923
  zone,
32909
32924
  }, {
32910
32925
  handleEvent: this.handleEvent.bind(this),
@@ -32997,6 +33012,7 @@ stores.inject(MyMetaStore, storeInstance);
32997
33012
  this.colorIndexByRange = {};
32998
33013
  this.hoveredTokens = [];
32999
33014
  this.hoveredContentEvaluation = "";
33015
+ this.hideHelp();
33000
33016
  }
33001
33017
  /**
33002
33018
  * Reset the current content to the active cell content
@@ -38618,6 +38634,7 @@ stores.inject(MyMetaStore, storeInstance);
38618
38634
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
38619
38635
  : undefined,
38620
38636
  wrapText: style.wrapping === "wrap" || content?.includes(NEWLINE) ? true : undefined,
38637
+ shrinkToFit: style.wrapping === "clip" ? true : undefined,
38621
38638
  },
38622
38639
  };
38623
38640
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -38638,6 +38655,7 @@ stores.inject(MyMetaStore, storeInstance);
38638
38655
  vertical: styles.alignment.vertical,
38639
38656
  horizontal: styles.alignment.horizontal,
38640
38657
  wrapText: styles.alignment.wrapText,
38658
+ shrinkToFit: styles.alignment.shrinkToFit,
38641
38659
  },
38642
38660
  };
38643
38661
  return pushElement(style, construct.styles);
@@ -50821,7 +50839,7 @@ stores.inject(MyMetaStore, storeInstance);
50821
50839
  });
50822
50840
  dataRange = this.props.definition.dataRange;
50823
50841
  get configurationErrorMessages() {
50824
- const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])];
50842
+ const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
50825
50843
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
50826
50844
  }
50827
50845
  get isDataRangeInvalid() {
@@ -50906,7 +50924,7 @@ stores.inject(MyMetaStore, storeInstance);
50906
50924
  });
50907
50925
  }
50908
50926
  get designErrorMessages() {
50909
- const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])];
50927
+ const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
50910
50928
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
50911
50929
  }
50912
50930
  get isRangeMinInvalid() {
@@ -51271,7 +51289,7 @@ stores.inject(MyMetaStore, storeInstance);
51271
51289
  const cancelledReasons = [
51272
51290
  ...(this.state.keyValueDispatchResult?.reasons || []),
51273
51291
  ...(this.state.baselineDispatchResult?.reasons || []),
51274
- ];
51292
+ ].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
51275
51293
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
51276
51294
  }
51277
51295
  get isKeyValueInvalid() {
@@ -53204,6 +53222,12 @@ stores.inject(MyMetaStore, storeInstance);
53204
53222
  case "ACTIVATE_SHEET":
53205
53223
  this.isSearchDirty = true;
53206
53224
  this.shouldFinalizeUpdateSelection = true;
53225
+ if (this.searchOptions.specificRange) {
53226
+ this.searchOptions.specificRange = {
53227
+ ...this.searchOptions.specificRange,
53228
+ sheetId: this.getters.getActiveSheetId(),
53229
+ };
53230
+ }
53207
53231
  break;
53208
53232
  case "REPLACE_SEARCH":
53209
53233
  for (const match of cmd.matches) {
@@ -53623,9 +53647,20 @@ stores.inject(MyMetaStore, storeInstance);
53623
53647
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
53624
53648
  this.store.updateSearchOptions({ specificRange });
53625
53649
  }
53650
+ get specificRange() {
53651
+ const range = this.store.searchOptions.specificRange;
53652
+ return range ? this.env.model.getters.getRangeString(range, "forceSheetReference") : "";
53653
+ }
53626
53654
  get pendingSearch() {
53627
53655
  return this.updateSearchContent.isDebouncePending();
53628
53656
  }
53657
+ get selectionInputKey() {
53658
+ // Selections input are made to work with objects linked to a sheet id. They store the active sheet id at their creation,
53659
+ // and have specific behaviour linked to it (eg. go back to the initial sheet after confirmation).
53660
+ // We don't want all those behaviors here, so we force the recreation of the component when the active sheet changes.
53661
+ // The only drawback is that the input loses focus when changing sheet.
53662
+ return this.env.model.getters.getActiveSheetId();
53663
+ }
53629
53664
  }
53630
53665
 
53631
53666
  css /* scss */ `
@@ -56081,8 +56116,6 @@ stores.inject(MyMetaStore, storeInstance);
56081
56116
  }
56082
56117
  const change = applyChange(range);
56083
56118
  switch (change.changeType) {
56084
- case "NONE":
56085
- return range;
56086
56119
  case "REMOVE":
56087
56120
  return undefined;
56088
56121
  default:
@@ -58900,7 +58933,7 @@ stores.inject(MyMetaStore, storeInstance);
58900
58933
  * @param sheetId an sheetId to adapt either range of that sheet specifically, or ranges pointing to that sheet
58901
58934
  * @param sheetName couple of old and new sheet names to adapt ranges pointing to that sheet
58902
58935
  */
58903
- adaptRanges(applyChange, sheetId, sheetName) { }
58936
+ adaptRanges(rangeAdapterFunctions, sheetId, sheetName) { }
58904
58937
  /**
58905
58938
  * Implement this method to clean unused external resources, such as images
58906
58939
  * stored on a server which have been deleted.
@@ -59496,7 +59529,7 @@ stores.inject(MyMetaStore, storeInstance);
59496
59529
  ];
59497
59530
  nextId = 1;
59498
59531
  cells = {};
59499
- adaptRanges(applyChange, sheetId, sheetName) {
59532
+ adaptRanges({ applyChange }, sheetId, sheetName) {
59500
59533
  for (const sheet of Object.keys(this.cells)) {
59501
59534
  for (const cell of Object.values(this.cells[sheet] || {})) {
59502
59535
  if (cell.isFormula) {
@@ -59718,7 +59751,7 @@ stores.inject(MyMetaStore, storeInstance);
59718
59751
  for (const position of positions) {
59719
59752
  const cell = this.getters.getCell(position);
59720
59753
  const xc = toXC(position.col, position.row);
59721
- const style = this.removeDefaultStyleValues(cell.style);
59754
+ const style = this.extractCustomStyle(cell);
59722
59755
  if (Object.keys(style).length) {
59723
59756
  const styleId = getItemId(style, styles);
59724
59757
  positionsByStyle[styleId] ??= [];
@@ -59764,10 +59797,14 @@ stores.inject(MyMetaStore, storeInstance);
59764
59797
  }
59765
59798
  }
59766
59799
  }
59767
- removeDefaultStyleValues(style) {
59768
- const cleanedStyle = { ...style };
59769
- for (const property in DEFAULT_STYLE) {
59770
- if (cleanedStyle[property] === DEFAULT_STYLE[property]) {
59800
+ extractCustomStyle(cell) {
59801
+ const cleanedStyle = { ...cell.style };
59802
+ const defaultStyle = isNumber(cell.content, DEFAULT_LOCALE)
59803
+ ? DEFAULT_NUMBER_STYLE
59804
+ : DEFAULT_STYLE;
59805
+ for (const property in cleanedStyle) {
59806
+ if ((property !== "align" || !cell.isFormula) &&
59807
+ cleanedStyle[property] === defaultStyle[property]) {
59771
59808
  delete cleanedStyle[property];
59772
59809
  }
59773
59810
  }
@@ -60117,9 +60154,9 @@ stores.inject(MyMetaStore, storeInstance);
60117
60154
  charts = {};
60118
60155
  createChart = chartFactory(this.getters);
60119
60156
  validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
60120
- adaptRanges(applyChange, sheetId, adaptSheetName) {
60157
+ adaptRanges(rangeAdapters) {
60121
60158
  for (const [chartId, chart] of Object.entries(this.charts)) {
60122
- this.history.update("charts", chartId, chart?.updateRanges(applyChange, sheetId, adaptSheetName));
60159
+ this.history.update("charts", chartId, chart?.updateRanges(rangeAdapters));
60123
60160
  }
60124
60161
  }
60125
60162
  // ---------------------------------------------------------------------------
@@ -60309,7 +60346,7 @@ stores.inject(MyMetaStore, storeInstance);
60309
60346
  "getAdaptedCfRanges",
60310
60347
  ];
60311
60348
  cfRules = {};
60312
- adaptCFFormulas(applyChange) {
60349
+ adaptCFFormulas({ applyChange, adaptFormulaString }) {
60313
60350
  for (const sheetId in this.cfRules) {
60314
60351
  for (const rule of this.cfRules[sheetId]) {
60315
60352
  if (rule.rule.type === "DataBarRule" && rule.rule.rangeValues) {
@@ -60333,7 +60370,7 @@ stores.inject(MyMetaStore, storeInstance);
60333
60370
  for (let i = 0; i < rule.rule.values.length; i++) {
60334
60371
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
60335
60372
  //@ts-expect-error
60336
- "values", i, this.getters.adaptFormulaStringDependencies(sheetId, rule.rule.values[i], applyChange));
60373
+ "values", i, adaptFormulaString(sheetId, rule.rule.values[i]));
60337
60374
  }
60338
60375
  }
60339
60376
  else if (rule.rule.type === "IconSetRule") {
@@ -60341,7 +60378,7 @@ stores.inject(MyMetaStore, storeInstance);
60341
60378
  if (rule.rule[inflectionPoint].type === "formula") {
60342
60379
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
60343
60380
  //@ts-expect-error
60344
- inflectionPoint, "value", this.getters.adaptFormulaStringDependencies(sheetId, rule.rule[inflectionPoint].value, applyChange));
60381
+ inflectionPoint, "value", adaptFormulaString(sheetId, rule.rule[inflectionPoint].value));
60345
60382
  }
60346
60383
  }
60347
60384
  }
@@ -60351,14 +60388,14 @@ stores.inject(MyMetaStore, storeInstance);
60351
60388
  if (ruleValue?.type === "formula" && ruleValue?.value) {
60352
60389
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
60353
60390
  //@ts-expect-error
60354
- value, "value", this.getters.adaptFormulaStringDependencies(sheetId, ruleValue.value, applyChange));
60391
+ value, "value", adaptFormulaString(sheetId, ruleValue.value));
60355
60392
  }
60356
60393
  }
60357
60394
  }
60358
60395
  }
60359
60396
  }
60360
60397
  }
60361
- adaptCFRanges(sheetId, applyChange) {
60398
+ adaptCFRanges(sheetId, { applyChange }) {
60362
60399
  for (const rule of this.cfRules[sheetId]) {
60363
60400
  for (const range of rule.ranges) {
60364
60401
  const change = applyChange(range);
@@ -60382,12 +60419,12 @@ stores.inject(MyMetaStore, storeInstance);
60382
60419
  }
60383
60420
  }
60384
60421
  }
60385
- adaptRanges(applyChange, sheetId) {
60422
+ adaptRanges(rangeAdapters, sheetId) {
60386
60423
  const sheetIds = sheetId ? [sheetId] : Object.keys(this.cfRules);
60387
60424
  for (const sheetId of sheetIds) {
60388
- this.adaptCFRanges(sheetId, applyChange);
60425
+ this.adaptCFRanges(sheetId, rangeAdapters);
60389
60426
  }
60390
- this.adaptCFFormulas(applyChange);
60427
+ this.adaptCFFormulas(rangeAdapters);
60391
60428
  }
60392
60429
  // ---------------------------------------------------------------------------
60393
60430
  // Command Handling
@@ -60764,23 +60801,23 @@ stores.inject(MyMetaStore, storeInstance);
60764
60801
  "getValidationRuleForCell",
60765
60802
  ];
60766
60803
  rules = {};
60767
- adaptRanges(applyChange, sheetId) {
60768
- this.adaptDVRanges(sheetId, applyChange);
60769
- this.adaptDVFormulas(applyChange);
60804
+ adaptRanges(rangeAdapters, sheetId) {
60805
+ this.adaptDVRanges(sheetId, rangeAdapters);
60806
+ this.adaptDVFormulas(rangeAdapters);
60770
60807
  }
60771
- adaptDVFormulas(applyChange) {
60808
+ adaptDVFormulas({ adaptFormulaString }) {
60772
60809
  for (const sheetId in this.rules) {
60773
60810
  const rules = this.rules[sheetId];
60774
60811
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
60775
60812
  const rule = this.rules[sheetId][ruleIndex];
60776
60813
  for (let valueIndex = 0; valueIndex < rule.criterion.values.length; valueIndex++) {
60777
- const value = this.getters.adaptFormulaStringDependencies(sheetId, rule.criterion.values[valueIndex], applyChange);
60814
+ const value = adaptFormulaString(sheetId, rule.criterion.values[valueIndex]);
60778
60815
  this.history.update("rules", sheetId, ruleIndex, "criterion", "values", valueIndex, value);
60779
60816
  }
60780
60817
  }
60781
60818
  }
60782
60819
  }
60783
- adaptDVRanges(sheetId, applyChange) {
60820
+ adaptDVRanges(sheetId, { applyChange }) {
60784
60821
  const rules = this.rules[sheetId];
60785
60822
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
60786
60823
  const rule = this.rules[sheetId][ruleIndex];
@@ -61054,7 +61091,7 @@ stores.inject(MyMetaStore, storeInstance);
61054
61091
  // ---------------------------------------------------------------------------
61055
61092
  // Command Handling
61056
61093
  // ---------------------------------------------------------------------------
61057
- adaptRanges(applyChange, sheetId) {
61094
+ adaptRanges({ applyChange }, sheetId) {
61058
61095
  for (const figure of this.getFigures(sheetId)) {
61059
61096
  const change = applyChange(this.getters.getRangeFromZone(sheetId, {
61060
61097
  left: figure.col,
@@ -61862,8 +61899,8 @@ stores.inject(MyMetaStore, storeInstance);
61862
61899
  break;
61863
61900
  }
61864
61901
  }
61865
- adaptRanges(applyChange, sheetId) {
61866
- this.applyRangeChangeOnSheet(sheetId, applyChange);
61902
+ adaptRanges(rangeAdapters, sheetId) {
61903
+ this.applyRangeChangeOnSheet(sheetId, rangeAdapters);
61867
61904
  }
61868
61905
  // ---------------------------------------------------------------------------
61869
61906
  // Getters
@@ -62165,7 +62202,7 @@ stores.inject(MyMetaStore, storeInstance);
62165
62202
  /**
62166
62203
  * Apply a range change on merges of a particular sheet.
62167
62204
  */
62168
- applyRangeChangeOnSheet(sheetId, applyChange) {
62205
+ applyRangeChangeOnSheet(sheetId, { applyChange }) {
62169
62206
  const merges = Object.entries(this.merges[sheetId] || {});
62170
62207
  for (const [mergeId, range] of merges) {
62171
62208
  if (range) {
@@ -62239,7 +62276,7 @@ stores.inject(MyMetaStore, storeInstance);
62239
62276
  };
62240
62277
  }
62241
62278
 
62242
- class RangeAdapter {
62279
+ class RangeAdapterPlugin {
62243
62280
  getters;
62244
62281
  providers = [];
62245
62282
  isAdaptingRanges = false;
@@ -62247,7 +62284,6 @@ stores.inject(MyMetaStore, storeInstance);
62247
62284
  this.getters = getters;
62248
62285
  }
62249
62286
  static getters = [
62250
- "adaptFormulaStringDependencies",
62251
62287
  "copyFormulaStringForSheet",
62252
62288
  "extendRange",
62253
62289
  "getRangeString",
@@ -62278,8 +62314,8 @@ stores.inject(MyMetaStore, storeInstance);
62278
62314
  throw new Error("Plugins cannot dispatch commands during adaptRanges phase");
62279
62315
  }
62280
62316
  const rangeAdapter = getRangeAdapter(cmd);
62281
- if (rangeAdapter?.applyChange) {
62282
- this.executeOnAllRanges(rangeAdapter.applyChange, rangeAdapter.sheetId, rangeAdapter.sheetName);
62317
+ if (rangeAdapter) {
62318
+ this.executeOnAllRanges(rangeAdapter);
62283
62319
  }
62284
62320
  }
62285
62321
  finalize() { }
@@ -62298,11 +62334,15 @@ stores.inject(MyMetaStore, storeInstance);
62298
62334
  return result;
62299
62335
  };
62300
62336
  }
62301
- executeOnAllRanges(adaptRange, sheetId, sheetName) {
62337
+ executeOnAllRanges(rangeAdapter) {
62302
62338
  this.isAdaptingRanges = true;
62303
- const func = this.verifyRangeRemoved(adaptRange);
62339
+ const adapterFunctions = {
62340
+ applyChange: this.verifyRangeRemoved(rangeAdapter.applyChange),
62341
+ adaptRangeString: (defaultSheetId, sheetXC) => adaptStringRange(defaultSheetId, sheetXC, rangeAdapter),
62342
+ adaptFormulaString: (defaultSheetId, formula) => adaptFormulaStringRanges(defaultSheetId, formula, rangeAdapter),
62343
+ };
62304
62344
  for (const provider of this.providers) {
62305
- provider(func, sheetId, sheetName);
62345
+ provider(adapterFunctions, rangeAdapter.sheetId, rangeAdapter.sheetName);
62306
62346
  }
62307
62347
  this.isAdaptingRanges = false;
62308
62348
  }
@@ -62470,18 +62510,6 @@ stores.inject(MyMetaStore, storeInstance);
62470
62510
  const unionOfZones = unionUnboundedZones(...zones);
62471
62511
  return this.getRangeFromZone(ranges[0].sheetId, unionOfZones);
62472
62512
  }
62473
- adaptFormulaStringDependencies(sheetId, formula, applyChange) {
62474
- if (!formula.startsWith("=")) {
62475
- return formula;
62476
- }
62477
- const compiledFormula = compile(formula);
62478
- const updatedDependencies = compiledFormula.dependencies.map((dep) => {
62479
- const range = this.getters.getRangeFromSheetXC(sheetId, dep);
62480
- const changedRange = applyChange(range);
62481
- return changedRange.changeType === "NONE" ? range : changedRange.range;
62482
- });
62483
- return this.getters.getFormulaString(sheetId, compiledFormula.tokens, updatedDependencies);
62484
- }
62485
62513
  /**
62486
62514
  * Copy a formula string to another sheet.
62487
62515
  *
@@ -63374,7 +63402,7 @@ stores.inject(MyMetaStore, storeInstance);
63374
63402
  static getters = ["getCoreTable", "getCoreTables", "getCoreTableMatchingTopLeft"];
63375
63403
  tables = {};
63376
63404
  nextTableId = 1;
63377
- adaptRanges(applyChange, sheetId) {
63405
+ adaptRanges({ applyChange }, sheetId) {
63378
63406
  for (const table of this.getCoreTables(sheetId)) {
63379
63407
  this.applyRangeChangeOnTable(sheetId, table, applyChange);
63380
63408
  }
@@ -64252,6 +64280,7 @@ stores.inject(MyMetaStore, storeInstance);
64252
64280
  "getMeasureCompiledFormula",
64253
64281
  "getPivotName",
64254
64282
  "isExistingPivot",
64283
+ "getMeasureFullDependencies",
64255
64284
  ];
64256
64285
  nextFormulaId = 1;
64257
64286
  pivots = {};
@@ -64334,12 +64363,12 @@ stores.inject(MyMetaStore, storeInstance);
64334
64363
  }
64335
64364
  case "UPDATE_PIVOT": {
64336
64365
  this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
64337
- this.compileCalculatedMeasures(cmd.pivot.measures);
64366
+ this.compileCalculatedMeasures(cmd.pivotId, cmd.pivot.measures);
64338
64367
  break;
64339
64368
  }
64340
64369
  }
64341
64370
  }
64342
- adaptRanges(applyChange) {
64371
+ adaptRanges({ applyChange, adaptFormulaString }) {
64343
64372
  for (const pivotId in this.pivots) {
64344
64373
  const definition = deepCopy(this.pivots[pivotId]?.definition);
64345
64374
  if (!definition) {
@@ -64352,22 +64381,22 @@ stores.inject(MyMetaStore, storeInstance);
64352
64381
  this.history.update("pivots", pivotId, "definition", newDefinition);
64353
64382
  }
64354
64383
  }
64355
- for (const sheetId in this.compiledMeasureFormulas) {
64356
- for (const formulaString in this.compiledMeasureFormulas[sheetId]) {
64357
- const compiledFormula = this.compiledMeasureFormulas[sheetId][formulaString];
64358
- const newDependencies = [];
64359
- for (const range of compiledFormula.dependencies) {
64360
- const change = applyChange(range);
64361
- if (change.changeType === "NONE") {
64362
- newDependencies.push(range);
64363
- }
64364
- else {
64365
- newDependencies.push(change.range);
64366
- }
64384
+ for (const pivotId in this.compiledMeasureFormulas) {
64385
+ for (const measureId in this.compiledMeasureFormulas[pivotId]) {
64386
+ const measure = this.pivots[pivotId]?.definition.measures.find((m) => m.id === measureId);
64387
+ if (!measure || !measure.computedBy) {
64388
+ continue;
64367
64389
  }
64368
- const newFormulaString = this.getters.getFormulaString(sheetId, compiledFormula.tokens, newDependencies);
64369
- if (newFormulaString !== formulaString) {
64370
- this.replaceMeasureFormula(sheetId, formulaString, newFormulaString);
64390
+ const sheetId = measure.computedBy.sheetId;
64391
+ const { formula: compiledFormula, dependencies: indirectDependencies } = this.compiledMeasureFormulas[pivotId][measureId];
64392
+ // adapt direct dependencies
64393
+ this.history.update("compiledMeasureFormulas", pivotId, measureId, "formula", "dependencies", compiledFormula.dependencies.map((range) => applyChange(range).range));
64394
+ // adapt all dependencies (including indirect)
64395
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", indirectDependencies.map((range) => applyChange(range).range));
64396
+ const oldFormulaString = measure.computedBy.formula;
64397
+ const newFormulaString = adaptFormulaString(sheetId, oldFormulaString);
64398
+ if (newFormulaString !== oldFormulaString) {
64399
+ this.replaceMeasureFormula(pivotId, measure, newFormulaString);
64371
64400
  }
64372
64401
  }
64373
64402
  }
@@ -64405,30 +64434,59 @@ stores.inject(MyMetaStore, storeInstance);
64405
64434
  isExistingPivot(pivotId) {
64406
64435
  return pivotId in this.pivots;
64407
64436
  }
64408
- getMeasureCompiledFormula(measure) {
64437
+ getMeasureCompiledFormula(pivotId, measure) {
64438
+ if (!measure.computedBy) {
64439
+ throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
64440
+ }
64441
+ return this.compiledMeasureFormulas[pivotId][measure.id].formula;
64442
+ }
64443
+ getMeasureFullDependencies(pivotId, measure) {
64409
64444
  if (!measure.computedBy) {
64410
64445
  throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
64411
64446
  }
64412
- const sheetId = measure.computedBy.sheetId;
64413
- return this.compiledMeasureFormulas[sheetId][measure.computedBy.formula];
64447
+ return this.compiledMeasureFormulas[pivotId][measure.id].dependencies;
64414
64448
  }
64415
64449
  // -------------------------------------------------------------------------
64416
64450
  // Private
64417
64451
  // -------------------------------------------------------------------------
64418
64452
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
64419
64453
  this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
64420
- this.compileCalculatedMeasures(pivot.measures);
64454
+ this.compileCalculatedMeasures(pivotId, pivot.measures);
64421
64455
  this.history.update("formulaIds", formulaId, pivotId);
64422
64456
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
64423
64457
  }
64424
- compileCalculatedMeasures(measures) {
64458
+ compileCalculatedMeasures(pivotId, measures) {
64425
64459
  for (const measure of measures) {
64426
64460
  if (measure.computedBy) {
64427
- const sheetId = measure.computedBy.sheetId;
64428
64461
  const compiledFormula = this.compileMeasureFormula(measure.computedBy.sheetId, measure.computedBy.formula);
64429
- this.history.update("compiledMeasureFormulas", sheetId, measure.computedBy.formula, compiledFormula);
64462
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "formula", compiledFormula);
64430
64463
  }
64431
64464
  }
64465
+ for (const measure of measures) {
64466
+ if (measure.computedBy) {
64467
+ const dependencies = this.computeMeasureFullDependencies(pivotId, measure);
64468
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", dependencies);
64469
+ }
64470
+ }
64471
+ }
64472
+ computeMeasureFullDependencies(pivotId, measure, exploredMeasures = new Set()) {
64473
+ const rangeDependencies = [];
64474
+ const definition = this.getPivotCoreDefinition(pivotId);
64475
+ const formula = this.getMeasureCompiledFormula(pivotId, measure);
64476
+ exploredMeasures.add(measure.id);
64477
+ for (const token of formula.tokens) {
64478
+ if (token.type !== "SYMBOL") {
64479
+ continue;
64480
+ }
64481
+ const otherMeasure = definition.measures.find((measureCandidate) => getCanonicalSymbolName(measureCandidate.id) === token.value &&
64482
+ measure.id !== measureCandidate.id);
64483
+ if (!otherMeasure || exploredMeasures.has(otherMeasure.id) || !otherMeasure.computedBy) {
64484
+ continue;
64485
+ }
64486
+ rangeDependencies.push(...this.computeMeasureFullDependencies(pivotId, otherMeasure, exploredMeasures));
64487
+ }
64488
+ rangeDependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
64489
+ return rangeDependencies;
64432
64490
  }
64433
64491
  insertPivot(position, formulaId, table) {
64434
64492
  this.resizeSheet(position.sheetId, position, table);
@@ -64488,21 +64546,16 @@ stores.inject(MyMetaStore, storeInstance);
64488
64546
  dependencies: rangeDependencies,
64489
64547
  };
64490
64548
  }
64491
- replaceMeasureFormula(sheetId, formulaString, newFormulaString) {
64492
- this.history.update("compiledMeasureFormulas", sheetId, formulaString, undefined);
64493
- this.history.update("compiledMeasureFormulas", sheetId, newFormulaString, this.compileMeasureFormula(sheetId, newFormulaString));
64494
- for (const pivotId in this.pivots) {
64495
- const pivot = this.pivots[pivotId];
64496
- if (!pivot) {
64497
- continue;
64498
- }
64499
- for (const measure of pivot.definition.measures) {
64500
- if (measure.computedBy?.formula === formulaString) {
64501
- const measureIndex = pivot.definition.measures.indexOf(measure);
64502
- this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", { formula: newFormulaString, sheetId });
64503
- }
64504
- }
64549
+ replaceMeasureFormula(pivotId, measure, newFormulaString) {
64550
+ const pivot = this.pivots[pivotId];
64551
+ if (!pivot) {
64552
+ return;
64505
64553
  }
64554
+ const measureIndex = pivot.definition.measures.indexOf(measure);
64555
+ this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", {
64556
+ formula: newFormulaString,
64557
+ sheetId: measure.computedBy.sheetId,
64558
+ });
64506
64559
  }
64507
64560
  checkSortedColumnInMeasures(definition) {
64508
64561
  const measures = definition.measures.map((measure) => measure.id);
@@ -65884,11 +65937,16 @@ stores.inject(MyMetaStore, storeInstance);
65884
65937
  return this.arrayFormulasToResults.get(formulasPosition);
65885
65938
  }
65886
65939
  /**
65887
- * Remove a node, also remove it from other nodes adjacency list
65940
+ * Remove a spreading relation for a given array formula position
65941
+ * and its result zone
65888
65942
  */
65889
65943
  removeNode(position) {
65944
+ const resultZone = this.arrayFormulasToResults.get(position);
65945
+ if (!resultZone) {
65946
+ return;
65947
+ }
65890
65948
  this.resultsToArrayFormulas.remove({
65891
- boundingBox: { sheetId: position.sheetId, zone: positionToZone(position) },
65949
+ boundingBox: { sheetId: position.sheetId, zone: resultZone },
65892
65950
  data: position,
65893
65951
  });
65894
65952
  this.arrayFormulasToResults.delete(position);
@@ -66176,6 +66234,10 @@ stores.inject(MyMetaStore, storeInstance);
66176
66234
  // empty matrix
66177
66235
  return createEvaluatedCell({ value: 0 }, this.getters.getLocale(), cellData);
66178
66236
  }
66237
+ if (nbRows === 1 && nbColumns === 1) {
66238
+ // single value matrix
66239
+ return createEvaluatedCell(nullValueToZeroValue(formulaReturn[0][0]), this.getters.getLocale(), cellData);
66240
+ }
66179
66241
  const resultZone = {
66180
66242
  top: formulaPosition.row,
66181
66243
  bottom: formulaPosition.row + nbRows - 1,
@@ -67862,6 +67924,7 @@ stores.inject(MyMetaStore, storeInstance);
67862
67924
  handle(cmd) {
67863
67925
  switch (cmd.type) {
67864
67926
  case "START":
67927
+ case "UPDATE_LOCALE":
67865
67928
  for (const sheetId of this.getters.getSheetIds()) {
67866
67929
  this.initializeSheet(sheetId);
67867
67930
  }
@@ -67983,7 +68046,7 @@ stores.inject(MyMetaStore, storeInstance);
67983
68046
  }
67984
68047
  const cell = this.getters.getCell(position);
67985
68048
  const colSize = this.getters.getColSize(position.sheetId, position.col);
67986
- return getDefaultCellHeight(this.ctx, cell, colSize);
68049
+ return getDefaultCellHeight(this.ctx, cell, this.getters.getLocale(), colSize);
67987
68050
  }
67988
68051
  isInMultiRowMerge(position) {
67989
68052
  const merge = this.getters.getMerge(position);
@@ -68030,14 +68093,16 @@ stores.inject(MyMetaStore, storeInstance);
68030
68093
  function withPivotPresentationLayer (PivotClass) {
68031
68094
  class PivotPresentationLayer extends PivotClass {
68032
68095
  getters;
68096
+ pivotId;
68033
68097
  cache = {};
68034
68098
  rankAsc = {};
68035
68099
  rankDesc = {};
68036
68100
  runningTotal = {};
68037
68101
  runningTotalInPercent = {};
68038
- constructor(custom, params) {
68102
+ constructor(pivotId, custom, params) {
68039
68103
  super(custom, params);
68040
68104
  this.getters = params.getters;
68105
+ this.pivotId = pivotId;
68041
68106
  }
68042
68107
  markAsDirtyForEvaluation() {
68043
68108
  this.cache = {};
@@ -68087,7 +68152,7 @@ stores.inject(MyMetaStore, storeInstance);
68087
68152
  return handleError(error, measure.aggregator.toUpperCase());
68088
68153
  }
68089
68154
  }
68090
- const formula = this.getters.getMeasureCompiledFormula(measure);
68155
+ const formula = this.getters.getMeasureCompiledFormula(this.pivotId, measure);
68091
68156
  const getSymbolValue = (symbolName) => {
68092
68157
  const { columns, rows } = this.definition;
68093
68158
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
@@ -68827,7 +68892,7 @@ stores.inject(MyMetaStore, storeInstance);
68827
68892
  const definition = deepCopy(this.getters.getPivotCoreDefinition(pivotId));
68828
68893
  if (!(pivotId in this.pivots)) {
68829
68894
  const Pivot = withPivotPresentationLayer(pivotRegistry.get(definition.type).ui);
68830
- this.pivots[pivotId] = new Pivot(this.custom, { definition, getters: this.getters });
68895
+ this.pivots[pivotId] = new Pivot(pivotId, this.custom, { definition, getters: this.getters });
68831
68896
  }
68832
68897
  else if (recreate) {
68833
68898
  this.pivots[pivotId].onDefinitionChange(definition);
@@ -70290,7 +70355,7 @@ stores.inject(MyMetaStore, storeInstance);
70290
70355
  cmd.cf.rule = {
70291
70356
  ...rule,
70292
70357
  rangeValues: rule.rangeValues
70293
- ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange)
70358
+ ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange).range
70294
70359
  : undefined,
70295
70360
  };
70296
70361
  }
@@ -83505,6 +83570,9 @@ stores.inject(MyMetaStore, storeInstance);
83505
83570
  if (style.alignment && style.alignment.wrapText) {
83506
83571
  alignAttrs.push(["wrapText", "1"]);
83507
83572
  }
83573
+ if (style.alignment && style.alignment.shrinkToFit) {
83574
+ alignAttrs.push(["shrinkToFit", "1"]);
83575
+ }
83508
83576
  if (alignAttrs.length > 0) {
83509
83577
  attributes.push(["applyAlignment", "1"]); // for Libre Office
83510
83578
  styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)}><alignment ${formatAttributes(alignAttrs)} /></xf> `);
@@ -84275,7 +84343,7 @@ stores.inject(MyMetaStore, storeInstance);
84275
84343
  this.config = this.setupConfig(config);
84276
84344
  this.session = this.setupSession(workbookData.revisionId);
84277
84345
  this.coreGetters = {};
84278
- this.range = new RangeAdapter(this.coreGetters);
84346
+ this.range = new RangeAdapterPlugin(this.coreGetters);
84279
84347
  this.coreGetters.getRangeString = this.range.getRangeString.bind(this.range);
84280
84348
  this.coreGetters.getRangeFromSheetXC = this.range.getRangeFromSheetXC.bind(this.range);
84281
84349
  this.coreGetters.createAdaptedRanges = this.range.createAdaptedRanges.bind(this.range);
@@ -84289,8 +84357,6 @@ stores.inject(MyMetaStore, storeInstance);
84289
84357
  this.coreGetters.extendRange = this.range.extendRange.bind(this.range);
84290
84358
  this.coreGetters.getRangesUnion = this.range.getRangesUnion.bind(this.range);
84291
84359
  this.coreGetters.removeRangesSheetPrefix = this.range.removeRangesSheetPrefix.bind(this.range);
84292
- this.coreGetters.adaptFormulaStringDependencies =
84293
- this.range.adaptFormulaStringDependencies.bind(this.range);
84294
84360
  this.coreGetters.copyFormulaStringForSheet = this.range.copyFormulaStringForSheet.bind(this.range);
84295
84361
  this.getters = {
84296
84362
  isReadonly: () => this.config.mode === "readonly" || this.config.mode === "dashboard",
@@ -85013,9 +85079,9 @@ stores.inject(MyMetaStore, storeInstance);
85013
85079
  exports.tokenize = tokenize;
85014
85080
 
85015
85081
 
85016
- __info__.version = "18.4.23";
85017
- __info__.date = "2026-01-07T16:21:07.502Z";
85018
- __info__.hash = "a0135e8";
85082
+ __info__.version = "18.4.25";
85083
+ __info__.date = "2026-01-21T11:06:11.131Z";
85084
+ __info__.hash = "161472d";
85019
85085
 
85020
85086
 
85021
85087
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);