@odoo/o-spreadsheet 16.2.28 → 16.2.31

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.
@@ -1695,6 +1695,9 @@ function parseFormat(formatString) {
1695
1695
  function formatValue(value, format) {
1696
1696
  switch (typeof value) {
1697
1697
  case "string":
1698
+ if (value.includes('\\"')) {
1699
+ return value.replace(/\\"/g, '"');
1700
+ }
1698
1701
  return value;
1699
1702
  case "boolean":
1700
1703
  return value ? "TRUE" : "FALSE";
@@ -2024,27 +2027,30 @@ function detectFormat(content) {
2024
2027
  }
2025
2028
  function createLargeNumberFormat(format, magnitude, postFix) {
2026
2029
  const internalFormat = parseFormat(format || "#,##0");
2027
- const largeNumberFormat = internalFormat
2028
- .map((formatPart) => {
2029
- if (formatPart.type === "NUMBER") {
2030
- return [
2031
- {
2032
- ...formatPart,
2033
- format: {
2034
- ...formatPart.format,
2035
- magnitude,
2036
- decimalPart: undefined,
2037
- },
2038
- },
2039
- {
2040
- type: "STRING",
2041
- format: postFix,
2042
- },
2043
- ];
2030
+ const largeNumberFormat = [];
2031
+ for (let i = 0; i < internalFormat.length; i++) {
2032
+ const formatPart = internalFormat[i];
2033
+ if (formatPart.type !== "NUMBER") {
2034
+ largeNumberFormat.push(formatPart);
2035
+ continue;
2044
2036
  }
2045
- return formatPart;
2046
- })
2047
- .flat();
2037
+ largeNumberFormat.push({
2038
+ ...formatPart,
2039
+ format: {
2040
+ ...formatPart.format,
2041
+ magnitude,
2042
+ decimalPart: undefined,
2043
+ },
2044
+ });
2045
+ largeNumberFormat.push({
2046
+ type: "STRING",
2047
+ format: postFix,
2048
+ });
2049
+ const nextFormatPart = internalFormat[i + 1];
2050
+ if ((nextFormatPart === null || nextFormatPart === void 0 ? void 0 : nextFormatPart.type) === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
2051
+ i++;
2052
+ }
2053
+ }
2048
2054
  return convertInternalFormatToFormat(largeNumberFormat);
2049
2055
  }
2050
2056
  function changeDecimalPlaces(format, step) {
@@ -4315,64 +4321,65 @@ exports.CommandResult = void 0;
4315
4321
  CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
4316
4322
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
4317
4323
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
4318
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
4319
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
4320
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
4321
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
4322
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
4323
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
4324
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
4325
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
4326
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
4327
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
4328
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
4329
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
4330
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
4331
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
4332
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
4333
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
4334
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
4335
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
4336
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
4337
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
4338
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
4339
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
4340
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
4341
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
4342
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
4343
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
4344
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
4345
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
4346
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
4347
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
4348
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
4349
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
4350
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
4351
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
4352
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
4353
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
4354
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
4355
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
4356
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
4357
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
4358
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
4359
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
4360
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
4361
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
4362
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
4363
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
4364
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
4365
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
4366
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
4367
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
4368
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
4369
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
4370
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
4371
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
4372
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
4373
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
4374
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4375
- CommandResult[CommandResult["NoChanges"] = 88] = "NoChanges";
4324
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
4325
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
4326
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
4327
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
4328
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
4329
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
4330
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
4331
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
4332
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
4333
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
4334
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
4335
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
4336
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
4337
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
4338
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
4339
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
4340
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
4341
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
4342
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
4343
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
4344
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
4345
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
4346
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
4347
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
4348
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
4349
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
4350
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
4351
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
4352
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
4353
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
4354
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
4355
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
4356
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
4357
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
4358
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
4359
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
4360
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
4361
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
4362
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
4363
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
4364
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
4365
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
4366
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
4367
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
4368
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
4369
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
4370
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
4371
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
4372
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
4373
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
4374
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
4375
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
4376
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
4377
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
4378
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
4379
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
4380
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
4381
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
4382
+ CommandResult[CommandResult["NoChanges"] = 89] = "NoChanges";
4376
4383
  })(exports.CommandResult || (exports.CommandResult = {}));
4377
4384
 
4378
4385
  function isMatrix(x) {
@@ -6271,14 +6278,8 @@ function createDataSets(getters, dataSetsString, sheetId, dataSetsHaveTitle) {
6271
6278
  : undefined));
6272
6279
  }
6273
6280
  }
6274
- else if (zone.left === zone.right && zone.top === zone.bottom) {
6275
- // A single cell. If it's only the title, the dataset is not added.
6276
- if (!dataSetsHaveTitle) {
6277
- dataSets.push(createDataSet(getters, dataSetSheetId, zone, undefined));
6278
- }
6279
- }
6280
6281
  else {
6281
- /* 1 row or 1 column */
6282
+ /* 1 cell, 1 row or 1 column */
6282
6283
  dataSets.push(createDataSet(getters, dataSetSheetId, zone, dataSetsHaveTitle
6283
6284
  ? {
6284
6285
  top: zone.top,
@@ -6328,8 +6329,10 @@ function toExcelDataset(getters, ds) {
6328
6329
  }
6329
6330
  const dataRange = ds.dataRange.clone({ zone: dataZone });
6330
6331
  return {
6331
- label: ds.labelCell ? getters.getRangeString(ds.labelCell, "forceSheetReference") : undefined,
6332
- range: getters.getRangeString(dataRange, "forceSheetReference"),
6332
+ label: ds.labelCell
6333
+ ? getters.getRangeString(ds.labelCell, "forceSheetReference", true)
6334
+ : undefined,
6335
+ range: getters.getRangeString(dataRange, "forceSheetReference", true),
6333
6336
  };
6334
6337
  }
6335
6338
  /**
@@ -6398,11 +6401,11 @@ function checkDataset(definition) {
6398
6401
  if (definition.dataSets) {
6399
6402
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
6400
6403
  if (invalidRanges) {
6401
- return 32 /* CommandResult.InvalidDataSet */;
6404
+ return 33 /* CommandResult.InvalidDataSet */;
6402
6405
  }
6403
6406
  const zones = definition.dataSets.map(toUnboundedZone);
6404
6407
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
6405
- return 32 /* CommandResult.InvalidDataSet */;
6408
+ return 33 /* CommandResult.InvalidDataSet */;
6406
6409
  }
6407
6410
  }
6408
6411
  return 0 /* CommandResult.Success */;
@@ -6411,7 +6414,7 @@ function checkLabelRange(definition) {
6411
6414
  if (definition.labelRange) {
6412
6415
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
6413
6416
  if (invalidLabels) {
6414
- return 33 /* CommandResult.InvalidLabelRange */;
6417
+ return 34 /* CommandResult.InvalidLabelRange */;
6415
6418
  }
6416
6419
  }
6417
6420
  return 0 /* CommandResult.Success */;
@@ -6484,22 +6487,22 @@ function getChartPositionAtCenterOfViewport(getters, chartSize) {
6484
6487
  const CfTerms = {
6485
6488
  Errors: {
6486
6489
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
6487
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6488
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6489
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6490
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6491
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6492
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6493
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6494
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6495
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6496
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6497
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6498
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6499
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6500
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6501
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6502
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6490
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6491
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6492
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6493
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6494
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6495
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6496
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6497
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6498
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6499
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6500
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6501
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6502
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6503
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6504
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6505
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6503
6506
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
6504
6507
  Unexpected: _lt("The rule is invalid for an unknown reason"),
6505
6508
  },
@@ -6527,20 +6530,20 @@ const ChartTerms = {
6527
6530
  Errors: {
6528
6531
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
6529
6532
  // BASIC CHART ERRORS (LINE | BAR | PIE)
6530
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6531
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6533
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6534
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6532
6535
  // SCORECARD CHART ERRORS
6533
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6534
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6536
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6537
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6535
6538
  // GAUGE CHART ERRORS
6536
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6537
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6538
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6539
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6540
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6541
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6542
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6543
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6539
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6540
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6541
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6542
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6543
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6544
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6545
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6546
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6544
6547
  },
6545
6548
  };
6546
6549
  const NumberFormatTerms = {
@@ -6854,6 +6857,9 @@ class BarChart extends AbstractChart {
6854
6857
  .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
6855
6858
  return {
6856
6859
  ...this.getDefinition(),
6860
+ labelRange: this.labelRange
6861
+ ? this.getters.getRangeString(this.labelRange, this.sheetId, true)
6862
+ : undefined,
6857
6863
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
6858
6864
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
6859
6865
  dataSets,
@@ -6946,7 +6952,7 @@ function createBarChartRuntime(chart, getters) {
6946
6952
 
6947
6953
  function isDataRangeValid(definition) {
6948
6954
  return definition.dataRange && !rangeReference.test(definition.dataRange)
6949
- ? 36 /* CommandResult.InvalidGaugeDataRange */
6955
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
6950
6956
  : 0 /* CommandResult.Success */;
6951
6957
  }
6952
6958
  function checkRangeLimits(check, batchValidations) {
@@ -6978,7 +6984,7 @@ function checkInflectionPointsValue(check, batchValidations) {
6978
6984
  function checkRangeMinBiggerThanRangeMax(definition) {
6979
6985
  if (definition.sectionRule) {
6980
6986
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
6981
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
6987
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
6982
6988
  }
6983
6989
  }
6984
6990
  return 0 /* CommandResult.Success */;
@@ -6987,9 +6993,9 @@ function checkEmpty(value, valueName) {
6987
6993
  if (value === "") {
6988
6994
  switch (valueName) {
6989
6995
  case "rangeMin":
6990
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
6996
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
6991
6997
  case "rangeMax":
6992
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
6998
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
6993
6999
  }
6994
7000
  }
6995
7001
  return 0 /* CommandResult.Success */;
@@ -6998,13 +7004,13 @@ function checkNaN(value, valueName) {
6998
7004
  if (isNaN(value)) {
6999
7005
  switch (valueName) {
7000
7006
  case "rangeMin":
7001
- return 38 /* CommandResult.GaugeRangeMinNaN */;
7007
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
7002
7008
  case "rangeMax":
7003
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
7009
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
7004
7010
  case "lowerInflectionPointValue":
7005
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
7011
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
7006
7012
  case "upperInflectionPointValue":
7007
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
7013
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
7008
7014
  }
7009
7015
  }
7010
7016
  return 0 /* CommandResult.Success */;
@@ -7418,6 +7424,9 @@ class LineChart extends AbstractChart {
7418
7424
  .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7419
7425
  return {
7420
7426
  ...this.getDefinition(),
7427
+ labelRange: this.labelRange
7428
+ ? this.getters.getRangeString(this.labelRange, this.sheetId, true)
7429
+ : undefined,
7421
7430
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
7422
7431
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
7423
7432
  dataSets,
@@ -7691,6 +7700,9 @@ class PieChart extends AbstractChart {
7691
7700
  .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7692
7701
  return {
7693
7702
  ...this.getDefinition(),
7703
+ labelRange: this.labelRange
7704
+ ? this.getters.getRangeString(this.labelRange, this.sheetId, true)
7705
+ : undefined,
7694
7706
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
7695
7707
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
7696
7708
  verticalAxisPosition: "left",
@@ -7762,12 +7774,12 @@ function createPieChartRuntime(chart, getters) {
7762
7774
 
7763
7775
  function checkKeyValue(definition) {
7764
7776
  return definition.keyValue && !rangeReference.test(definition.keyValue)
7765
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
7777
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
7766
7778
  : 0 /* CommandResult.Success */;
7767
7779
  }
7768
7780
  function checkBaseline(definition) {
7769
7781
  return definition.baseline && !rangeReference.test(definition.baseline)
7770
- ? 35 /* CommandResult.InvalidScorecardBaseline */
7782
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
7771
7783
  : 0 /* CommandResult.Success */;
7772
7784
  }
7773
7785
  class ScorecardChart extends AbstractChart {
@@ -8497,7 +8509,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
8497
8509
  });
8498
8510
  }
8499
8511
  }
8500
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
8512
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
8501
8513
  const { col, row } = anchor;
8502
8514
  env.model.selection.selectZone({ cell: { col, row }, zone });
8503
8515
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -8520,13 +8532,13 @@ const AddFilterInteractiveContent = {
8520
8532
  };
8521
8533
  function interactiveAddFilter(env, sheetId, target) {
8522
8534
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
8523
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
8535
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
8524
8536
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
8525
8537
  }
8526
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
8538
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
8527
8539
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
8528
8540
  }
8529
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
8541
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
8530
8542
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
8531
8543
  }
8532
8544
  }
@@ -8548,7 +8560,7 @@ function handlePasteResult(env, result) {
8548
8560
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
8549
8561
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
8550
8562
  }
8551
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
8563
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
8552
8564
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
8553
8565
  }
8554
8566
  }
@@ -9134,6 +9146,12 @@ const INSERT_LINK = (env) => {
9134
9146
  let { col, row } = env.model.getters.getActivePosition();
9135
9147
  env.model.dispatch("OPEN_CELL_POPOVER", { col, row, popoverType: "LinkEditor" });
9136
9148
  };
9149
+ const INSERT_LINK_NAME = (env) => {
9150
+ const sheetId = env.model.getters.getActiveSheetId();
9151
+ const { col, row } = env.model.getters.getActivePosition();
9152
+ const cell = env.model.getters.getEvaluatedCell({ sheetId, col, row });
9153
+ return cell && cell.link ? _lt("Edit link") : _lt("Insert link");
9154
+ };
9137
9155
  //------------------------------------------------------------------------------
9138
9156
  // Filters action
9139
9157
  //------------------------------------------------------------------------------
@@ -9271,7 +9289,7 @@ cellMenuRegistry
9271
9289
  action: DELETE_CELL_SHIFT_LEFT,
9272
9290
  })
9273
9291
  .add("insert_link", {
9274
- name: _lt("Insert link"),
9292
+ name: INSERT_LINK_NAME,
9275
9293
  separator: true,
9276
9294
  sequence: 150,
9277
9295
  action: INSERT_LINK,
@@ -16225,7 +16243,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
16225
16243
  const sheetId = env.model.getters.getActiveSheetId();
16226
16244
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
16227
16245
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
16228
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
16246
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
16229
16247
  env.raiseError(MergeErrorMessage);
16230
16248
  }
16231
16249
  }
@@ -17021,11 +17039,11 @@ class LineBarPieConfigPanel extends owl.Component {
17021
17039
  }
17022
17040
  get isDatasetInvalid() {
17023
17041
  var _a;
17024
- return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidDataSet */));
17042
+ return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidDataSet */));
17025
17043
  }
17026
17044
  get isLabelInvalid() {
17027
17045
  var _a;
17028
- return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
17046
+ return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */));
17029
17047
  }
17030
17048
  onUpdateDataSetsHaveTitle(ev) {
17031
17049
  this.props.updateChart(this.props.figureId, {
@@ -17463,7 +17481,7 @@ class GaugeChartConfigPanel extends owl.Component {
17463
17481
  }
17464
17482
  get isDataRangeInvalid() {
17465
17483
  var _a;
17466
- return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */));
17484
+ return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */));
17467
17485
  }
17468
17486
  onDataRangeChanged(ranges) {
17469
17487
  this.dataRange = ranges[0];
@@ -17542,28 +17560,28 @@ class GaugeChartDesignPanel extends owl.Component {
17542
17560
  }
17543
17561
  isRangeMinInvalid() {
17544
17562
  var _a, _b, _c;
17545
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */)) ||
17546
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */)) ||
17547
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
17563
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */)) ||
17564
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */)) ||
17565
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
17548
17566
  }
17549
17567
  isRangeMaxInvalid() {
17550
17568
  var _a, _b, _c;
17551
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */)) ||
17552
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */)) ||
17553
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
17569
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */)) ||
17570
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */)) ||
17571
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
17554
17572
  }
17555
17573
  // ---------------------------------------------------------------------------
17556
17574
  // COLOR_SECTION_TEMPLATE
17557
17575
  // ---------------------------------------------------------------------------
17558
17576
  get isLowerInflectionPointInvalid() {
17559
17577
  var _a, _b;
17560
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
17561
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
17578
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
17579
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
17562
17580
  }
17563
17581
  get isUpperInflectionPointInvalid() {
17564
17582
  var _a, _b;
17565
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
17566
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
17583
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
17584
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
17567
17585
  }
17568
17586
  updateInflectionPointValue(attr, ev) {
17569
17587
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -17676,11 +17694,11 @@ class ScorecardChartConfigPanel extends owl.Component {
17676
17694
  }
17677
17695
  get isKeyValueInvalid() {
17678
17696
  var _a;
17679
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */));
17697
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */));
17680
17698
  }
17681
17699
  get isBaselineInvalid() {
17682
17700
  var _a;
17683
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */));
17701
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */));
17684
17702
  }
17685
17703
  onKeyValueRangeChanged(ranges) {
17686
17704
  this.keyValue = ranges[0];
@@ -18534,11 +18552,11 @@ class ConditionalFormattingPanel extends owl.Component {
18534
18552
  ****************************************************************************/
18535
18553
  get isValue1Invalid() {
18536
18554
  var _a;
18537
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(51 /* CommandResult.FirstArgMissing */));
18555
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.FirstArgMissing */));
18538
18556
  }
18539
18557
  get isValue2Invalid() {
18540
18558
  var _a;
18541
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.SecondArgMissing */));
18559
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(53 /* CommandResult.SecondArgMissing */));
18542
18560
  }
18543
18561
  toggleStyle(tool) {
18544
18562
  const style = this.state.rules.cellIs.style;
@@ -18555,17 +18573,17 @@ class ConditionalFormattingPanel extends owl.Component {
18555
18573
  isValueInvalid(threshold) {
18556
18574
  switch (threshold) {
18557
18575
  case "minimum":
18558
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
18559
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
18560
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
18561
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
18576
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
18577
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
18578
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
18579
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
18562
18580
  case "midpoint":
18563
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
18564
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
18565
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
18581
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
18582
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
18583
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
18566
18584
  case "maximum":
18567
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
18568
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
18585
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
18586
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
18569
18587
  default:
18570
18588
  return false;
18571
18589
  }
@@ -18614,13 +18632,13 @@ class ConditionalFormattingPanel extends owl.Component {
18614
18632
  isInflectionPointInvalid(inflectionPoint) {
18615
18633
  switch (inflectionPoint) {
18616
18634
  case "lowerInflectionPoint":
18617
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
18618
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
18619
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
18635
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
18636
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
18637
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
18620
18638
  case "upperInflectionPoint":
18621
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
18622
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
18623
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
18639
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
18640
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
18641
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
18624
18642
  default:
18625
18643
  return true;
18626
18644
  }
@@ -19957,14 +19975,13 @@ class Composer extends owl.Component {
19957
19975
  setup() {
19958
19976
  owl.onMounted(() => {
19959
19977
  const el = this.composerRef.el;
19978
+ if (this.props.isDefaultFocus) {
19979
+ this.env.focusableElement.setFocusableElement(el);
19980
+ }
19960
19981
  this.contentHelper.updateEl(el);
19961
19982
  this.processContent();
19962
19983
  this.contentHelper.scrollSelectionIntoView();
19963
19984
  });
19964
- owl.onWillUnmount(() => {
19965
- var _a, _b;
19966
- (_b = (_a = this.props).onComposerUnmounted) === null || _b === void 0 ? void 0 : _b.call(_a);
19967
- });
19968
19985
  owl.onPatched(() => {
19969
19986
  if (!this.isKeyStillDown) {
19970
19987
  this.processContent();
@@ -19975,7 +19992,8 @@ class Composer extends owl.Component {
19975
19992
  // Handlers
19976
19993
  // ---------------------------------------------------------------------------
19977
19994
  processArrowKeys(ev) {
19978
- if (this.env.model.getters.isSelectingForComposer()) {
19995
+ if (this.env.model.getters.isSelectingForComposer() ||
19996
+ this.env.model.getters.getEditionMode() === "inactive") {
19979
19997
  this.functionDescriptionState.showDescription = false;
19980
19998
  // Prevent the default content editable behavior which moves the cursor
19981
19999
  ev.preventDefault();
@@ -20016,21 +20034,23 @@ class Composer extends owl.Component {
20016
20034
  var _a;
20017
20035
  ev.preventDefault();
20018
20036
  ev.stopPropagation();
20019
- if (this.autoCompleteState.showProvider) {
20020
- const autoCompleteValue = (_a = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]) === null || _a === void 0 ? void 0 : _a.text;
20021
- if (autoCompleteValue) {
20022
- this.autoComplete(autoCompleteValue);
20023
- return;
20037
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
20038
+ if (this.autoCompleteState.showProvider) {
20039
+ const autoCompleteValue = (_a = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]) === null || _a === void 0 ? void 0 : _a.text;
20040
+ if (autoCompleteValue) {
20041
+ this.autoComplete(autoCompleteValue);
20042
+ return;
20043
+ }
20024
20044
  }
20025
- }
20026
- else {
20027
- // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
20028
- // we can't let the model think that it is for a ref selection.
20029
- // todo: check if this can be removed someday
20030
- this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
20045
+ else {
20046
+ // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
20047
+ // we can't let the model think that it is for a ref selection.
20048
+ // todo: check if this can be removed someday
20049
+ this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
20050
+ }
20051
+ this.env.model.dispatch("STOP_EDITION");
20031
20052
  }
20032
20053
  const direction = ev.shiftKey ? "left" : "right";
20033
- this.env.model.dispatch("STOP_EDITION");
20034
20054
  this.env.model.selection.moveAnchorCell(direction, 1);
20035
20055
  }
20036
20056
  processEnterKey(ev) {
@@ -20075,6 +20095,9 @@ class Composer extends owl.Component {
20075
20095
  this.compositionActive = false;
20076
20096
  }
20077
20097
  onKeydown(ev) {
20098
+ if (this.env.model.getters.getEditionMode() === "inactive") {
20099
+ return;
20100
+ }
20078
20101
  let handler = this.keyMapping[ev.key];
20079
20102
  if (handler) {
20080
20103
  handler.call(this, ev);
@@ -20085,22 +20108,45 @@ class Composer extends owl.Component {
20085
20108
  }
20086
20109
  }
20087
20110
  updateCursorIfNeeded() {
20088
- if (!this.env.model.getters.isSelectingForComposer()) {
20111
+ const moveCursor = !this.env.model.getters.isSelectingForComposer() &&
20112
+ !(this.env.model.getters.getEditionMode() === "inactive");
20113
+ if (moveCursor) {
20089
20114
  const { start, end } = this.contentHelper.getCurrentSelection();
20090
20115
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
20091
20116
  this.isKeyStillDown = true;
20092
20117
  }
20093
20118
  }
20119
+ onPaste(ev) {
20120
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
20121
+ ev.stopPropagation();
20122
+ }
20123
+ }
20094
20124
  /*
20095
20125
  * Triggered automatically by the content-editable between the keydown and key up
20096
20126
  * */
20097
- onInput() {
20098
- if (this.props.focus === "inactive" || !this.shouldProcessInputEvents) {
20127
+ onInput(ev) {
20128
+ var _a, _b;
20129
+ if (!this.shouldProcessInputEvents) {
20099
20130
  return;
20100
20131
  }
20132
+ if (ev.inputType === "insertFromPaste" &&
20133
+ this.env.model.getters.getEditionMode() === "inactive") {
20134
+ return;
20135
+ }
20136
+ ev.stopPropagation();
20137
+ let content;
20138
+ if (this.env.model.getters.getEditionMode() === "inactive") {
20139
+ content = ev.data || "";
20140
+ }
20141
+ else {
20142
+ content = this.contentHelper.getText();
20143
+ }
20144
+ if (this.props.focus === "inactive") {
20145
+ return (_b = (_a = this.props).onComposerCellFocused) === null || _b === void 0 ? void 0 : _b.call(_a, content);
20146
+ }
20101
20147
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
20102
20148
  this.env.model.dispatch("SET_CURRENT_CONTENT", {
20103
- content: this.contentHelper.getText(),
20149
+ content,
20104
20150
  selection: this.contentHelper.getCurrentSelection(),
20105
20151
  });
20106
20152
  }
@@ -20171,9 +20217,8 @@ class Composer extends owl.Component {
20171
20217
  }
20172
20218
  const newSelection = this.contentHelper.getCurrentSelection();
20173
20219
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
20174
- if (this.props.focus === "inactive") {
20175
- this.props.onComposerContentFocused(newSelection);
20176
- }
20220
+ this.props.onComposerContentFocused();
20221
+ if (this.props.focus === "inactive") ;
20177
20222
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", newSelection);
20178
20223
  this.processTokenAtCursor();
20179
20224
  }
@@ -20397,14 +20442,16 @@ Composer.template = "o-spreadsheet-Composer";
20397
20442
  Composer.components = { TextValueProvider, FunctionDescriptionProvider };
20398
20443
  Composer.defaultProps = {
20399
20444
  inputStyle: "",
20445
+ isDefaultFocus: false,
20400
20446
  };
20401
20447
  Composer.props = {
20402
- focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
20403
- onComposerContentFocused: Function,
20404
20448
  inputStyle: { type: String, optional: true },
20405
20449
  rect: { type: Object, optional: true },
20406
20450
  delimitation: { type: Object, optional: true },
20407
- onComposerUnmounted: { type: Function, optional: true },
20451
+ focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
20452
+ onComposerCellFocused: { type: Function, optional: true },
20453
+ onComposerContentFocused: Function,
20454
+ isDefaultFocus: { type: Boolean, optional: true },
20408
20455
  };
20409
20456
 
20410
20457
  const COMPOSER_BORDER_WIDTH = 3 * 0.4 * window.devicePixelRatio || 1;
@@ -20436,46 +20483,28 @@ css /* scss */ `
20436
20483
  * It also applies the style of the cell to the composer input.
20437
20484
  */
20438
20485
  class GridComposer extends owl.Component {
20486
+ constructor() {
20487
+ super(...arguments);
20488
+ // TODORAR see if we can keep it undefined
20489
+ this.rect = this.defaultRect;
20490
+ this.isEditing = false;
20491
+ }
20492
+ get defaultRect() {
20493
+ return { x: 0, y: 0, width: 0, height: 0 };
20494
+ }
20439
20495
  setup() {
20440
- this.gridComposerRef = owl.useRef("gridComposer");
20441
- this.composerState = owl.useState({
20442
- rect: undefined,
20443
- delimitation: undefined,
20444
- });
20445
- const { sheetId, col, row } = this.env.model.getters.getActivePosition();
20446
- this.zone = this.env.model.getters.expandZone(sheetId, positionToZone({ col, row }));
20447
- this.rect = this.env.model.getters.getVisibleRect(this.zone);
20448
- this.isCellReferenceVisible = false;
20449
- owl.onMounted(() => {
20450
- const el = this.gridComposerRef.el;
20451
- this.composerState.rect = {
20452
- x: this.rect.x,
20453
- y: this.rect.y,
20454
- width: el.clientWidth,
20455
- height: el.clientHeight,
20456
- };
20457
- this.composerState.delimitation = {
20458
- width: el.parentElement.clientWidth,
20459
- height: el.parentElement.clientHeight,
20460
- };
20461
- });
20462
20496
  owl.onWillUpdateProps(() => {
20463
- if (this.isCellReferenceVisible) {
20464
- return;
20465
- }
20466
- const sheetId = this.env.model.getters.getActiveSheetId();
20467
- const zone = this.env.model.getters.getSelectedZone();
20468
- const rect = this.env.model.getters.getVisibleRect(zone);
20469
- if (!deepEquals(rect, this.rect) ||
20470
- sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
20471
- this.isCellReferenceVisible = true;
20472
- }
20497
+ this.updateComponentPosition();
20498
+ this.updateCellReferenceVisibility();
20473
20499
  });
20474
20500
  }
20475
20501
  get shouldDisplayCellReference() {
20476
20502
  return this.isCellReferenceVisible;
20477
20503
  }
20478
20504
  get cellReference() {
20505
+ if (!this.env.model.getters.getCurrentEditedCell()) {
20506
+ return "";
20507
+ }
20479
20508
  const { col, row, sheetId } = this.env.model.getters.getCurrentEditedCell();
20480
20509
  const prefixSheet = sheetId !== this.env.model.getters.getActiveSheetId();
20481
20510
  return `${prefixSheet ? getComposerSheetName(this.env.model.getters.getSheetName(sheetId)) + "!" : ""}${toXC(col, row)}`;
@@ -20487,7 +20516,27 @@ class GridComposer extends owl.Component {
20487
20516
  top: `${top - GRID_CELL_REFERENCE_TOP_OFFSET}px`,
20488
20517
  });
20489
20518
  }
20519
+ get composerProps() {
20520
+ const { width, height } = this.env.model.getters.getSheetViewDimensionWithHeaders();
20521
+ return {
20522
+ rect: { ...this.rect },
20523
+ delimitation: {
20524
+ width,
20525
+ height,
20526
+ },
20527
+ focus: this.props.focus,
20528
+ isDefaultFocus: true,
20529
+ onComposerContentFocused: this.props.onComposerContentFocused,
20530
+ onComposerCellFocused: this.props.onComposerCellFocused,
20531
+ };
20532
+ }
20490
20533
  get containerStyle() {
20534
+ if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
20535
+ return `
20536
+ position: absolute;
20537
+ z-index: -1000;
20538
+ `;
20539
+ }
20491
20540
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
20492
20541
  const cell = this.env.model.getters.getActiveCell();
20493
20542
  const position = this.env.model.getters.getActivePosition();
@@ -20507,6 +20556,8 @@ class GridComposer extends owl.Component {
20507
20556
  if (!isFormula) {
20508
20557
  textAlign = style.align || cell.defaultAlign;
20509
20558
  }
20559
+ const maxHeight = this.props.gridDims.height - this.rect.y;
20560
+ const maxWidth = this.props.gridDims.width - this.rect.x;
20510
20561
  /**
20511
20562
  * min-size is on the container, not the composer element, because we want to have the same size as the cell by default,
20512
20563
  * including all the paddings/margins of the composer
@@ -20518,6 +20569,8 @@ class GridComposer extends owl.Component {
20518
20569
  top: `${top}px`,
20519
20570
  "min-width": `${width + 1}px`,
20520
20571
  "min-height": `${height + 1}px`,
20572
+ "max-width": `${maxWidth}px`,
20573
+ "max-height": `${maxHeight}px`,
20521
20574
  background,
20522
20575
  color,
20523
20576
  "font-size": `${fontSizeInPixels(fontSize)}px`,
@@ -20527,22 +20580,40 @@ class GridComposer extends owl.Component {
20527
20580
  "text-align": textAlign,
20528
20581
  });
20529
20582
  }
20530
- get composerStyle() {
20531
- const maxHeight = this.props.gridDims.height - this.rect.y;
20532
- const maxWidth = this.props.gridDims.width - this.rect.x;
20533
- return cssPropertiesToCss({
20534
- "max-width": `${maxWidth}px`,
20535
- "max-height": `${maxHeight}px`,
20536
- });
20583
+ updateComponentPosition() {
20584
+ const isEditing = this.env.model.getters.getEditionMode() !== "inactive";
20585
+ if (this.isEditing !== isEditing) {
20586
+ this.isEditing = isEditing;
20587
+ if (!isEditing) {
20588
+ this.rect = this.defaultRect;
20589
+ this.env.focusableElement.focus();
20590
+ return;
20591
+ }
20592
+ const position = this.env.model.getters.getActivePosition();
20593
+ const zone = this.env.model.getters.expandZone(position.sheetId, positionToZone(position));
20594
+ this.rect = this.env.model.getters.getVisibleRect(zone);
20595
+ }
20596
+ }
20597
+ updateCellReferenceVisibility() {
20598
+ if (this.isCellReferenceVisible || this.env.model.getters.getEditionMode() === "inactive") {
20599
+ return;
20600
+ }
20601
+ const sheetId = this.env.model.getters.getActiveSheetId();
20602
+ const zone = this.env.model.getters.getSelectedZone();
20603
+ const rect = this.env.model.getters.getVisibleRect(zone);
20604
+ if (!deepEquals(rect, this.rect) ||
20605
+ sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
20606
+ this.isCellReferenceVisible = true;
20607
+ }
20537
20608
  }
20538
20609
  }
20539
20610
  GridComposer.template = "o-spreadsheet-GridComposer";
20540
20611
  GridComposer.components = { Composer };
20541
20612
  GridComposer.props = {
20542
20613
  focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
20543
- onComposerUnmounted: Function,
20544
20614
  onComposerContentFocused: Function,
20545
20615
  gridDims: Object,
20616
+ onComposerCellFocused: Function,
20546
20617
  };
20547
20618
 
20548
20619
  const CSS$1 = css /* scss */ `
@@ -21133,7 +21204,6 @@ class GridOverlay extends owl.Component {
21133
21204
  this.props.onCellDoubleClicked(col, row);
21134
21205
  }
21135
21206
  onContextMenu(ev) {
21136
- ev.preventDefault();
21137
21207
  const [col, row] = this.getCartesianCoordinates(ev);
21138
21208
  this.props.onCellRightClicked(col, row, { x: ev.clientX, y: ev.clientY });
21139
21209
  }
@@ -22360,17 +22430,16 @@ class Grid extends owl.Component {
22360
22430
  menuItems: [],
22361
22431
  });
22362
22432
  this.gridRef = owl.useRef("grid");
22363
- this.hiddenInput = owl.useRef("hiddenInput");
22364
22433
  this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
22365
22434
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
22366
22435
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
22367
22436
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
22368
22437
  owl.useExternalListener(document.body, "copy", this.copy.bind(this, false));
22369
22438
  owl.useExternalListener(document.body, "paste", this.paste);
22370
- owl.onMounted(() => this.focus());
22371
- this.props.exposeFocus(() => this.focus());
22439
+ owl.onMounted(() => this.focusDefaultElement());
22440
+ this.props.exposeFocus(() => this.focusDefaultElement());
22372
22441
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimensionWithHeaders());
22373
- owl.useEffect(() => this.focus(), () => [this.env.model.getters.getActiveSheetId()]);
22442
+ owl.useEffect(() => this.focusDefaultElement(), () => [this.env.model.getters.getActiveSheetId()]);
22374
22443
  this.onMouseWheel = useWheelHandler((deltaX, deltaY) => {
22375
22444
  this.moveCanvas(deltaX, deltaY);
22376
22445
  this.hoveredCell.col = undefined;
@@ -22393,13 +22462,12 @@ class Grid extends owl.Component {
22393
22462
  if (this.env.model.getters.hasOpenedPopover()) {
22394
22463
  this.closeOpenedPopover();
22395
22464
  }
22396
- this.focus();
22465
+ this.focusDefaultElement();
22397
22466
  }
22398
- focus() {
22399
- var _a;
22467
+ focusDefaultElement() {
22400
22468
  if (!this.env.model.getters.getSelectedFigureId() &&
22401
22469
  this.env.model.getters.getEditionMode() === "inactive") {
22402
- (_a = this.hiddenInput.el) === null || _a === void 0 ? void 0 : _a.focus();
22470
+ this.env.focusableElement.focus();
22403
22471
  }
22404
22472
  }
22405
22473
  get gridEl() {
@@ -22544,19 +22612,6 @@ class Grid extends owl.Component {
22544
22612
  return;
22545
22613
  }
22546
22614
  }
22547
- onInput(ev) {
22548
- // the user meant to paste in the sheet, not open the composer with the pasted content
22549
- if (!ev.isComposing && ev.inputType === "insertFromPaste") {
22550
- return;
22551
- }
22552
- if (ev.data) {
22553
- // if the user types a character on the grid, it means he wants to start composing the selected cell with that
22554
- // character
22555
- ev.preventDefault();
22556
- ev.stopPropagation();
22557
- this.props.onGridComposerCellFocused(ev.data);
22558
- }
22559
- }
22560
22615
  // ---------------------------------------------------------------------------
22561
22616
  // Context Menu
22562
22617
  // ---------------------------------------------------------------------------
@@ -22653,7 +22708,7 @@ class Grid extends owl.Component {
22653
22708
  }
22654
22709
  closeMenu() {
22655
22710
  this.menuState.isOpen = false;
22656
- this.focus();
22711
+ this.focusDefaultElement();
22657
22712
  }
22658
22713
  }
22659
22714
  Grid.template = "o-spreadsheet-Grid";
@@ -27005,7 +27060,7 @@ function normalizeV9(formula) {
27005
27060
  * a breaking change is made in the way the state is handled, and an upgrade
27006
27061
  * function should be defined
27007
27062
  */
27008
- const CURRENT_VERSION = 12;
27063
+ const CURRENT_VERSION = 12.5;
27009
27064
  const INITIAL_SHEET_ID = "Sheet1";
27010
27065
  /**
27011
27066
  * This function tries to load anything that could look like a valid
@@ -27271,6 +27326,31 @@ const MIGRATIONS = [
27271
27326
  return data;
27272
27327
  },
27273
27328
  },
27329
+ {
27330
+ description: "Fix datafilter duplication",
27331
+ from: 12,
27332
+ to: 12.5,
27333
+ applyMigration(data) {
27334
+ for (let sheet of data.sheets || []) {
27335
+ let knownDataFilterZones = [];
27336
+ for (let filterTable of sheet.filterTables || []) {
27337
+ const zone = toZone(filterTable.range);
27338
+ // See commit message for the details
27339
+ const intersectZoneIndex = knownDataFilterZones.findIndex((knownZone) => overlap(knownZone, zone));
27340
+ if (intersectZoneIndex !== -1) {
27341
+ knownDataFilterZones[intersectZoneIndex] = zone;
27342
+ }
27343
+ else {
27344
+ knownDataFilterZones.push(zone);
27345
+ }
27346
+ }
27347
+ sheet.filterTables = knownDataFilterZones.map((zone) => ({
27348
+ range: zoneToXc(zone),
27349
+ }));
27350
+ }
27351
+ return data;
27352
+ },
27353
+ },
27274
27354
  ];
27275
27355
  /**
27276
27356
  * This function is used to repair faulty data independently of the migration.
@@ -28017,7 +28097,7 @@ class BordersPlugin extends CorePlugin {
28017
28097
  const currentBorder = this.getCellBorder(cmd);
28018
28098
  const areAllNewBordersUndefined = !((_a = cmd.border) === null || _a === void 0 ? void 0 : _a.bottom) && !((_b = cmd.border) === null || _b === void 0 ? void 0 : _b.left) && !((_c = cmd.border) === null || _c === void 0 ? void 0 : _c.right) && !((_d = cmd.border) === null || _d === void 0 ? void 0 : _d.top);
28019
28099
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
28020
- return 88 /* CommandResult.NoChanges */;
28100
+ return 89 /* CommandResult.NoChanges */;
28021
28101
  }
28022
28102
  return 0 /* CommandResult.Success */;
28023
28103
  }
@@ -28291,13 +28371,13 @@ class CellPlugin extends CorePlugin {
28291
28371
  /*
28292
28372
  * Reconstructs the original formula string based on a normalized form and its dependencies
28293
28373
  */
28294
- buildFormulaContent(sheetId, cell, dependencies) {
28374
+ buildFormulaContent(sheetId, cell, dependencies, useFixedZone = false) {
28295
28375
  const ranges = dependencies || cell.dependencies;
28296
28376
  let rangeIndex = 0;
28297
28377
  return concat(cell.compiledFormula.tokens.map((token) => {
28298
28378
  if (token.type === "REFERENCE") {
28299
28379
  const range = ranges[rangeIndex++];
28300
- return this.getters.getRangeString(range, sheetId);
28380
+ return this.getters.getRangeString(range, sheetId, useFixedZone);
28301
28381
  }
28302
28382
  return token.value;
28303
28383
  }));
@@ -28535,9 +28615,9 @@ class CellPlugin extends CorePlugin {
28535
28615
  checkUselessClearCell(cmd) {
28536
28616
  const cell = this.getters.getCell(cmd);
28537
28617
  if (!cell)
28538
- return 88 /* CommandResult.NoChanges */;
28618
+ return 89 /* CommandResult.NoChanges */;
28539
28619
  if (!cell.content && !cell.style && !cell.format) {
28540
- return 88 /* CommandResult.NoChanges */;
28620
+ return 89 /* CommandResult.NoChanges */;
28541
28621
  }
28542
28622
  return 0 /* CommandResult.Success */;
28543
28623
  }
@@ -28746,13 +28826,13 @@ class ChartPlugin extends CorePlugin {
28746
28826
  }
28747
28827
  checkChartDuplicate(cmd) {
28748
28828
  return this.getters.getFigureSheetId(cmd.id)
28749
- ? 84 /* CommandResult.DuplicatedChartId */
28829
+ ? 85 /* CommandResult.DuplicatedChartId */
28750
28830
  : 0 /* CommandResult.Success */;
28751
28831
  }
28752
28832
  checkChartExists(cmd) {
28753
28833
  return this.getters.getFigureSheetId(cmd.id)
28754
28834
  ? 0 /* CommandResult.Success */
28755
- : 85 /* CommandResult.ChartDoesNotExist */;
28835
+ : 86 /* CommandResult.ChartDoesNotExist */;
28756
28836
  }
28757
28837
  }
28758
28838
  ChartPlugin.getters = [
@@ -28867,7 +28947,13 @@ class ConditionalFormatPlugin extends CorePlugin {
28867
28947
  }
28868
28948
  }
28869
28949
  exportForExcel(data) {
28870
- this.export(data);
28950
+ if (data.sheets) {
28951
+ for (let sheet of data.sheets) {
28952
+ if (this.cfRules[sheet.id]) {
28953
+ sheet.conditionalFormats = this.cfRules[sheet.id].map((rule) => this.mapToConditionalFormat(sheet.id, rule, { useFixedReference: true }));
28954
+ }
28955
+ }
28956
+ }
28871
28957
  }
28872
28958
  // ---------------------------------------------------------------------------
28873
28959
  // Getters
@@ -28917,11 +29003,11 @@ class ConditionalFormatPlugin extends CorePlugin {
28917
29003
  // ---------------------------------------------------------------------------
28918
29004
  // Private
28919
29005
  // ---------------------------------------------------------------------------
28920
- mapToConditionalFormat(sheetId, cf) {
29006
+ mapToConditionalFormat(sheetId, cf, options = { useFixedReference: false }) {
28921
29007
  return {
28922
29008
  ...cf,
28923
29009
  ranges: cf.ranges.map((range) => {
28924
- return this.getters.getRangeString(range, sheetId);
29010
+ return this.getters.getRangeString(range, sheetId, options.useFixedReference);
28925
29011
  }),
28926
29012
  };
28927
29013
  }
@@ -28954,10 +29040,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28954
29040
  return 27 /* CommandResult.InvalidSheetId */;
28955
29041
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
28956
29042
  if (ruleIndex === -1)
28957
- return 71 /* CommandResult.InvalidConditionalFormatId */;
29043
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28958
29044
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
28959
29045
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
28960
- return 71 /* CommandResult.InvalidConditionalFormatId */;
29046
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28961
29047
  }
28962
29048
  return 0 /* CommandResult.Success */;
28963
29049
  }
@@ -28998,10 +29084,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28998
29084
  const errors = [];
28999
29085
  const isEmpty = (value) => value === undefined || value === "";
29000
29086
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
29001
- errors.push(51 /* CommandResult.FirstArgMissing */);
29087
+ errors.push(52 /* CommandResult.FirstArgMissing */);
29002
29088
  }
29003
29089
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
29004
- errors.push(52 /* CommandResult.SecondArgMissing */);
29090
+ errors.push(53 /* CommandResult.SecondArgMissing */);
29005
29091
  }
29006
29092
  return errors.length ? errors : 0 /* CommandResult.Success */;
29007
29093
  }
@@ -29013,15 +29099,15 @@ class ConditionalFormatPlugin extends CorePlugin {
29013
29099
  (threshold.value === "" || isNaN(threshold.value))) {
29014
29100
  switch (thresholdName) {
29015
29101
  case "min":
29016
- return 53 /* CommandResult.MinNaN */;
29102
+ return 54 /* CommandResult.MinNaN */;
29017
29103
  case "max":
29018
- return 55 /* CommandResult.MaxNaN */;
29104
+ return 56 /* CommandResult.MaxNaN */;
29019
29105
  case "mid":
29020
- return 54 /* CommandResult.MidNaN */;
29106
+ return 55 /* CommandResult.MidNaN */;
29021
29107
  case "upperInflectionPoint":
29022
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
29108
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
29023
29109
  case "lowerInflectionPoint":
29024
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
29110
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
29025
29111
  }
29026
29112
  }
29027
29113
  return 0 /* CommandResult.Success */;
@@ -29035,15 +29121,15 @@ class ConditionalFormatPlugin extends CorePlugin {
29035
29121
  catch (error) {
29036
29122
  switch (thresholdName) {
29037
29123
  case "min":
29038
- return 58 /* CommandResult.MinInvalidFormula */;
29124
+ return 59 /* CommandResult.MinInvalidFormula */;
29039
29125
  case "max":
29040
- return 60 /* CommandResult.MaxInvalidFormula */;
29126
+ return 61 /* CommandResult.MaxInvalidFormula */;
29041
29127
  case "mid":
29042
- return 59 /* CommandResult.MidInvalidFormula */;
29128
+ return 60 /* CommandResult.MidInvalidFormula */;
29043
29129
  case "upperInflectionPoint":
29044
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
29130
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
29045
29131
  case "lowerInflectionPoint":
29046
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
29132
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
29047
29133
  }
29048
29134
  }
29049
29135
  return 0 /* CommandResult.Success */;
@@ -29060,7 +29146,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29060
29146
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
29061
29147
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
29062
29148
  Number(minValue) > Number(maxValue)) {
29063
- return 48 /* CommandResult.LowerBiggerThanUpper */;
29149
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
29064
29150
  }
29065
29151
  return 0 /* CommandResult.Success */;
29066
29152
  }
@@ -29070,7 +29156,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29070
29156
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
29071
29157
  rule.minimum.type === rule.maximum.type &&
29072
29158
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
29073
- return 47 /* CommandResult.MinBiggerThanMax */;
29159
+ return 48 /* CommandResult.MinBiggerThanMax */;
29074
29160
  }
29075
29161
  return 0 /* CommandResult.Success */;
29076
29162
  }
@@ -29082,7 +29168,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29082
29168
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
29083
29169
  rule.midpoint.type === rule.maximum.type &&
29084
29170
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
29085
- return 49 /* CommandResult.MidBiggerThanMax */;
29171
+ return 50 /* CommandResult.MidBiggerThanMax */;
29086
29172
  }
29087
29173
  return 0 /* CommandResult.Success */;
29088
29174
  }
@@ -29094,7 +29180,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29094
29180
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
29095
29181
  rule.minimum.type === rule.midpoint.type &&
29096
29182
  stringToNumber(minValue) >= stringToNumber(midValue)) {
29097
- return 50 /* CommandResult.MinBiggerThanMid */;
29183
+ return 51 /* CommandResult.MinBiggerThanMid */;
29098
29184
  }
29099
29185
  return 0 /* CommandResult.Success */;
29100
29186
  }
@@ -29195,13 +29281,13 @@ class FigurePlugin extends CorePlugin {
29195
29281
  checkFigureExists(sheetId, figureId) {
29196
29282
  var _a;
29197
29283
  if (((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === undefined) {
29198
- return 70 /* CommandResult.FigureDoesNotExist */;
29284
+ return 71 /* CommandResult.FigureDoesNotExist */;
29199
29285
  }
29200
29286
  return 0 /* CommandResult.Success */;
29201
29287
  }
29202
29288
  checkFigureDuplicate(figureId) {
29203
29289
  if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29204
- return 82 /* CommandResult.DuplicatedFigureId */;
29290
+ return 83 /* CommandResult.DuplicatedFigureId */;
29205
29291
  }
29206
29292
  return 0 /* CommandResult.Success */;
29207
29293
  }
@@ -29303,12 +29389,12 @@ class FiltersPlugin extends CorePlugin {
29303
29389
  switch (cmd.type) {
29304
29390
  case "CREATE_FILTER_TABLE":
29305
29391
  if (!areZonesContinuous(...cmd.target)) {
29306
- return 81 /* CommandResult.NonContinuousTargets */;
29392
+ return 82 /* CommandResult.NonContinuousTargets */;
29307
29393
  }
29308
29394
  const zone = union(...cmd.target);
29309
29395
  const checkFilterOverlap = () => {
29310
29396
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
29311
- return 78 /* CommandResult.FilterOverlap */;
29397
+ return 79 /* CommandResult.FilterOverlap */;
29312
29398
  }
29313
29399
  return 0 /* CommandResult.Success */;
29314
29400
  };
@@ -29316,7 +29402,7 @@ class FiltersPlugin extends CorePlugin {
29316
29402
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
29317
29403
  for (let merge of mergesInTarget) {
29318
29404
  if (overlap(zone, merge)) {
29319
- return 80 /* CommandResult.MergeInFilter */;
29405
+ return 81 /* CommandResult.MergeInFilter */;
29320
29406
  }
29321
29407
  }
29322
29408
  return 0 /* CommandResult.Success */;
@@ -29326,7 +29412,7 @@ class FiltersPlugin extends CorePlugin {
29326
29412
  for (let merge of cmd.target) {
29327
29413
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
29328
29414
  if (overlap(filterTable.zone, merge)) {
29329
- return 80 /* CommandResult.MergeInFilter */;
29415
+ return 81 /* CommandResult.MergeInFilter */;
29330
29416
  }
29331
29417
  }
29332
29418
  }
@@ -29826,10 +29912,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
29826
29912
  : this.getters.getNumberRows(cmd.sheetId);
29827
29913
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
29828
29914
  if (hiddenElements.size >= elements) {
29829
- return 66 /* CommandResult.TooManyHiddenElements */;
29915
+ return 67 /* CommandResult.TooManyHiddenElements */;
29830
29916
  }
29831
29917
  else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
29832
- return 86 /* CommandResult.InvalidHeaderIndex */;
29918
+ return 87 /* CommandResult.InvalidHeaderIndex */;
29833
29919
  }
29834
29920
  else {
29835
29921
  return 0 /* CommandResult.Success */;
@@ -30373,7 +30459,7 @@ class MergePlugin extends CorePlugin {
30373
30459
  for (const zone of target) {
30374
30460
  for (const zone2 of target) {
30375
30461
  if (zone !== zone2 && overlap(zone, zone2)) {
30376
- return 65 /* CommandResult.MergeOverlap */;
30462
+ return 66 /* CommandResult.MergeOverlap */;
30377
30463
  }
30378
30464
  }
30379
30465
  }
@@ -30387,7 +30473,7 @@ class MergePlugin extends CorePlugin {
30387
30473
  for (const zone of target) {
30388
30474
  if ((zone.left < xSplit && zone.right >= xSplit) ||
30389
30475
  (zone.top < ySplit && zone.bottom >= ySplit)) {
30390
- return 75 /* CommandResult.FrozenPaneOverlap */;
30476
+ return 76 /* CommandResult.FrozenPaneOverlap */;
30391
30477
  }
30392
30478
  }
30393
30479
  return 0 /* CommandResult.Success */;
@@ -30850,8 +30936,9 @@ class RangeAdapter {
30850
30936
  *
30851
30937
  * @param range the range (received from getRangeFromXC or getRangeFromZone)
30852
30938
  * @param forSheetId the id of the sheet where the range string is supposed to be used.
30939
+ * @param [useFixedZone=false] if true, the range will be returned with fixed row and column
30853
30940
  */
30854
- getRangeString(range, forSheetId) {
30941
+ getRangeString(range, forSheetId, useFixedZone = false) {
30855
30942
  if (!range) {
30856
30943
  return INCORRECT_RANGE_STRING;
30857
30944
  }
@@ -30878,7 +30965,7 @@ class RangeAdapter {
30878
30965
  if (prefixSheet && !sheetName) {
30879
30966
  return INCORRECT_RANGE_STRING;
30880
30967
  }
30881
- let rangeString = this.getRangePartString(rangeImpl, 0);
30968
+ let rangeString = this.getRangePartString(rangeImpl, 0, useFixedZone);
30882
30969
  if (rangeImpl.parts && rangeImpl.parts.length === 2) {
30883
30970
  // this if converts A2:A2 into A2 except if any part of the original range had fixed row or column (with $)
30884
30971
  if (rangeImpl.zone.top !== rangeImpl.zone.bottom ||
@@ -30888,7 +30975,7 @@ class RangeAdapter {
30888
30975
  rangeImpl.parts[1].rowFixed ||
30889
30976
  rangeImpl.parts[1].colFixed) {
30890
30977
  rangeString += ":";
30891
- rangeString += this.getRangePartString(rangeImpl, 1);
30978
+ rangeString += this.getRangePartString(rangeImpl, 1, useFixedZone);
30892
30979
  }
30893
30980
  }
30894
30981
  return `${prefixSheet ? sheetName + "!" : ""}${rangeString}`;
@@ -30918,13 +31005,14 @@ class RangeAdapter {
30918
31005
  /**
30919
31006
  * Get a Xc string that represent a part of a range
30920
31007
  */
30921
- getRangePartString(range, part) {
30922
- const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
31008
+ getRangePartString(range, part, useFixedZone = false) {
31009
+ var _a, _b;
31010
+ const colFixed = range.parts && ((_a = range.parts[part]) === null || _a === void 0 ? void 0 : _a.colFixed) ? "$" : "";
30923
31011
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
30924
- const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
31012
+ const rowFixed = range.parts && ((_b = range.parts[part]) === null || _b === void 0 ? void 0 : _b.rowFixed) ? "$" : "";
30925
31013
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
30926
31014
  let str = "";
30927
- if (range.isFullCol) {
31015
+ if (range.isFullCol && !useFixedZone) {
30928
31016
  if (part === 0 && range.unboundedZone.hasHeader) {
30929
31017
  str = colFixed + col + rowFixed + row;
30930
31018
  }
@@ -30932,7 +31020,7 @@ class RangeAdapter {
30932
31020
  str = colFixed + col;
30933
31021
  }
30934
31022
  }
30935
- else if (range.isFullRow) {
31023
+ else if (range.isFullRow && !useFixedZone) {
30936
31024
  if (part === 0 && range.unboundedZone.hasHeader) {
30937
31025
  str = colFixed + col + rowFixed + row;
30938
31026
  }
@@ -31011,10 +31099,10 @@ class SheetPlugin extends CorePlugin {
31011
31099
  ? this.getNumberCols(cmd.sheetId)
31012
31100
  : this.getNumberRows(cmd.sheetId);
31013
31101
  if (cmd.base < 0 || cmd.base >= elements) {
31014
- return 86 /* CommandResult.InvalidHeaderIndex */;
31102
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31015
31103
  }
31016
31104
  else if (cmd.quantity <= 0) {
31017
- return 87 /* CommandResult.InvalidQuantity */;
31105
+ return 88 /* CommandResult.InvalidQuantity */;
31018
31106
  }
31019
31107
  return 0 /* CommandResult.Success */;
31020
31108
  case "REMOVE_COLUMNS_ROWS": {
@@ -31022,7 +31110,7 @@ class SheetPlugin extends CorePlugin {
31022
31110
  ? this.getNumberCols(cmd.sheetId)
31023
31111
  : this.getNumberRows(cmd.sheetId);
31024
31112
  if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31025
- return 86 /* CommandResult.InvalidHeaderIndex */;
31113
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31026
31114
  }
31027
31115
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
31028
31116
  return 8 /* CommandResult.NotEnoughElements */;
@@ -31462,18 +31550,18 @@ class SheetPlugin extends CorePlugin {
31462
31550
  checkRowFreezeQuantity(cmd) {
31463
31551
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
31464
31552
  ? 0 /* CommandResult.Success */
31465
- : 74 /* CommandResult.InvalidFreezeQuantity */;
31553
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
31466
31554
  }
31467
31555
  checkColFreezeQuantity(cmd) {
31468
31556
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
31469
31557
  ? 0 /* CommandResult.Success */
31470
- : 74 /* CommandResult.InvalidFreezeQuantity */;
31558
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
31471
31559
  }
31472
31560
  checkRowFreezeOverlapMerge(cmd) {
31473
31561
  const merges = this.getters.getMerges(cmd.sheetId);
31474
31562
  for (let merge of merges) {
31475
31563
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
31476
- return 65 /* CommandResult.MergeOverlap */;
31564
+ return 66 /* CommandResult.MergeOverlap */;
31477
31565
  }
31478
31566
  }
31479
31567
  return 0 /* CommandResult.Success */;
@@ -31482,7 +31570,7 @@ class SheetPlugin extends CorePlugin {
31482
31570
  const merges = this.getters.getMerges(cmd.sheetId);
31483
31571
  for (let merge of merges) {
31484
31572
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
31485
- return 65 /* CommandResult.MergeOverlap */;
31573
+ return 66 /* CommandResult.MergeOverlap */;
31486
31574
  }
31487
31575
  }
31488
31576
  return 0 /* CommandResult.Success */;
@@ -32246,10 +32334,8 @@ class EvaluationPlugin extends UIPlugin {
32246
32334
  * that are actually present in the grid.
32247
32335
  */
32248
32336
  function range(range) {
32337
+ assertRangeValid(range);
32249
32338
  const sheetId = range.sheetId;
32250
- if (!isZoneValid(range.zone)) {
32251
- throw new InvalidReferenceError();
32252
- }
32253
32339
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
32254
32340
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
32255
32341
  const sheetZone = getters.getSheetZone(sheetId);
@@ -32284,23 +32370,26 @@ class EvaluationPlugin extends UIPlugin {
32284
32370
  * The `compute` of the formula's function must process it completely
32285
32371
  */
32286
32372
  function refFn(range, isMeta, functionName, paramNumber) {
32373
+ assertRangeValid(range);
32287
32374
  if (isMeta) {
32288
32375
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
32289
32376
  return { value: zoneToXc(range.zone) };
32290
32377
  }
32291
- if (!isZoneValid(range.zone)) {
32292
- throw new InvalidReferenceError();
32293
- }
32294
32378
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
32295
32379
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
32296
32380
  throw new Error(paramNumber
32297
32381
  ? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
32298
32382
  : _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
32299
32383
  }
32384
+ return readCell(range);
32385
+ }
32386
+ function assertRangeValid(range) {
32387
+ if (!isZoneValid(range.zone)) {
32388
+ throw new InvalidReferenceError();
32389
+ }
32300
32390
  if (range.invalidSheetName) {
32301
32391
  throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
32302
32392
  }
32303
- return readCell(range);
32304
32393
  }
32305
32394
  return [refFn, range, evalContext];
32306
32395
  }
@@ -32320,6 +32409,10 @@ class EvaluationPlugin extends UIPlugin {
32320
32409
  if (cell.format !== evaluatedCell.format) {
32321
32410
  exportedCellData.computedFormat = evaluatedCell.format;
32322
32411
  }
32412
+ // if there is a formula but no dependencies (maybe because the cell is in error), no need to recompute the formula text
32413
+ if (cell.isFormula && cell.dependencies.length) {
32414
+ exportedCellData.content = this.getters.buildFormulaContent(sheet.id, cell, cell.dependencies, true);
32415
+ }
32323
32416
  }
32324
32417
  }
32325
32418
  }
@@ -32800,7 +32893,7 @@ class FilterEvaluationPlugin extends UIPlugin {
32800
32893
  switch (cmd.type) {
32801
32894
  case "UPDATE_FILTER":
32802
32895
  if (!this.getters.getFilterId(cmd)) {
32803
- return 79 /* CommandResult.FilterNotFound */;
32896
+ return 80 /* CommandResult.FilterNotFound */;
32804
32897
  }
32805
32898
  break;
32806
32899
  }
@@ -33747,7 +33840,7 @@ class SheetViewPlugin extends UIPlugin {
33747
33840
  }
33748
33841
  checkPositiveDimension(cmd) {
33749
33842
  if (cmd.width < 0 || cmd.height < 0) {
33750
- return 68 /* CommandResult.InvalidViewportSize */;
33843
+ return 69 /* CommandResult.InvalidViewportSize */;
33751
33844
  }
33752
33845
  return 0 /* CommandResult.Success */;
33753
33846
  }
@@ -33757,7 +33850,7 @@ class SheetViewPlugin extends UIPlugin {
33757
33850
  cmd.gridOffsetY === this.gridOffsetY &&
33758
33851
  cmd.width === width &&
33759
33852
  cmd.height === height) {
33760
- return 76 /* CommandResult.ValuesNotChanged */;
33853
+ return 77 /* CommandResult.ValuesNotChanged */;
33761
33854
  }
33762
33855
  return 0 /* CommandResult.Success */;
33763
33856
  }
@@ -33765,7 +33858,7 @@ class SheetViewPlugin extends UIPlugin {
33765
33858
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
33766
33859
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
33767
33860
  (!pane.canScrollVertically && offsetY > 0)) {
33768
- return 69 /* CommandResult.InvalidScrollingDirection */;
33861
+ return 70 /* CommandResult.InvalidScrollingDirection */;
33769
33862
  }
33770
33863
  return 0 /* CommandResult.Success */;
33771
33864
  }
@@ -34021,7 +34114,7 @@ class AutofillPlugin extends UIPlugin {
34021
34114
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
34022
34115
  return 0 /* CommandResult.Success */;
34023
34116
  }
34024
- return 45 /* CommandResult.InvalidAutofillSelection */;
34117
+ return 46 /* CommandResult.InvalidAutofillSelection */;
34025
34118
  case "AUTOFILL_AUTO":
34026
34119
  const zone = this.getters.getSelectedZone();
34027
34120
  return zone.top === zone.bottom
@@ -34623,7 +34716,7 @@ class CellPopoverPlugin extends UIPlugin {
34623
34716
  cellPopoverRegistry.get(cmd.popoverType);
34624
34717
  }
34625
34718
  catch (error) {
34626
- return 72 /* CommandResult.InvalidCellPopover */;
34719
+ return 73 /* CommandResult.InvalidCellPopover */;
34627
34720
  }
34628
34721
  return 0 /* CommandResult.Success */;
34629
34722
  default:
@@ -35826,21 +35919,6 @@ class SelectionInputPlugin extends UIPlugin {
35826
35919
  // ---------------------------------------------------------------------------
35827
35920
  // Command Handling
35828
35921
  // ---------------------------------------------------------------------------
35829
- allowDispatch(cmd) {
35830
- switch (cmd.type) {
35831
- case "ADD_EMPTY_RANGE":
35832
- if (this.inputHasSingleRange && this.ranges.length === 1) {
35833
- return 30 /* CommandResult.MaximumRangesReached */;
35834
- }
35835
- break;
35836
- case "CHANGE_RANGE":
35837
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
35838
- return 30 /* CommandResult.MaximumRangesReached */;
35839
- }
35840
- break;
35841
- }
35842
- return 0 /* CommandResult.Success */;
35843
- }
35844
35922
  handleEvent(event) {
35845
35923
  const xc = zoneToXc(event.anchor.zone);
35846
35924
  const inputSheetId = this.activeSheet;
@@ -36051,6 +36129,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
36051
36129
  // ---------------------------------------------------------------------------
36052
36130
  allowDispatch(cmd) {
36053
36131
  var _a, _b;
36132
+ switch (cmd.type) {
36133
+ case "FOCUS_RANGE":
36134
+ case "CHANGE_RANGE":
36135
+ case "ADD_EMPTY_RANGE":
36136
+ case "REMOVE_RANGE":
36137
+ if (!this.inputs[cmd.id]) {
36138
+ return 31 /* CommandResult.InvalidInputId */;
36139
+ }
36140
+ }
36054
36141
  switch (cmd.type) {
36055
36142
  case "FOCUS_RANGE":
36056
36143
  const index = (_a = this.currentInput) === null || _a === void 0 ? void 0 : _a.getIndex(cmd.rangeId);
@@ -36058,9 +36145,19 @@ class SelectionInputsManagerPlugin extends UIPlugin {
36058
36145
  return 29 /* CommandResult.InputAlreadyFocused */;
36059
36146
  }
36060
36147
  break;
36061
- }
36062
- if (this.currentInput) {
36063
- return this.currentInput.allowDispatch(cmd);
36148
+ case "ADD_EMPTY_RANGE":
36149
+ const input = this.inputs[cmd.id];
36150
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
36151
+ return 30 /* CommandResult.MaximumRangesReached */;
36152
+ }
36153
+ break;
36154
+ case "CHANGE_RANGE": {
36155
+ const input = this.inputs[cmd.id];
36156
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
36157
+ return 30 /* CommandResult.MaximumRangesReached */;
36158
+ }
36159
+ break;
36160
+ }
36064
36161
  }
36065
36162
  return 0 /* CommandResult.Success */;
36066
36163
  }
@@ -37040,7 +37137,7 @@ class SortPlugin extends UIPlugin {
37040
37137
  /*Test the presence of single cells*/
37041
37138
  const singleCells = positions(zone).some(({ col, row }) => !this.getters.isInMerge({ sheetId, col, row }));
37042
37139
  if (singleCells) {
37043
- return 63 /* CommandResult.InvalidSortZone */;
37140
+ return 64 /* CommandResult.InvalidSortZone */;
37044
37141
  }
37045
37142
  return 0 /* CommandResult.Success */;
37046
37143
  }
@@ -37059,7 +37156,7 @@ class SortPlugin extends UIPlugin {
37059
37156
  ];
37060
37157
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
37061
37158
  })) {
37062
- return 63 /* CommandResult.InvalidSortZone */;
37159
+ return 64 /* CommandResult.InvalidSortZone */;
37063
37160
  }
37064
37161
  return 0 /* CommandResult.Success */;
37065
37162
  }
@@ -37699,7 +37796,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
37699
37796
  for (const zone of this.getPasteZones(target)) {
37700
37797
  if ((zone.left < xSplit && zone.right >= xSplit) ||
37701
37798
  (zone.top < ySplit && zone.bottom >= ySplit)) {
37702
- return 75 /* CommandResult.FrozenPaneOverlap */;
37799
+ return 76 /* CommandResult.FrozenPaneOverlap */;
37703
37800
  }
37704
37801
  }
37705
37802
  return 0 /* CommandResult.Success */;
@@ -38087,7 +38184,7 @@ class ClipboardFigureState {
38087
38184
  }
38088
38185
  isPasteAllowed(target, option) {
38089
38186
  if (target.length === 0) {
38090
- return 73 /* CommandResult.EmptyTarget */;
38187
+ return 74 /* CommandResult.EmptyTarget */;
38091
38188
  }
38092
38189
  if ((option === null || option === void 0 ? void 0 : option.pasteOption) !== undefined) {
38093
38190
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -38804,7 +38901,7 @@ class EditionPlugin extends UIPlugin {
38804
38901
  validateSelection(length, start, end) {
38805
38902
  return start >= 0 && start <= length && end >= 0 && end <= length
38806
38903
  ? 0 /* CommandResult.Success */
38807
- : 46 /* CommandResult.WrongComposerSelection */;
38904
+ : 47 /* CommandResult.WrongComposerSelection */;
38808
38905
  }
38809
38906
  onColumnsRemoved(cmd) {
38810
38907
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -39116,9 +39213,10 @@ class EditionPlugin extends UIPlugin {
39116
39213
  */
39117
39214
  getReferencedRanges() {
39118
39215
  const editionSheetId = this.getters.getEditionSheet();
39119
- return this.currentTokens
39216
+ const referenceRanges = this.currentTokens
39120
39217
  .filter((token) => token.type === "REFERENCE")
39121
39218
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
39219
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
39122
39220
  }
39123
39221
  /**
39124
39222
  * Function used to determine when composer selection can start.
@@ -39721,7 +39819,7 @@ class GridSelectionPlugin extends UIPlugin {
39721
39819
  const headers = [cmd.base, ...cmd.elements];
39722
39820
  const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
39723
39821
  if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
39724
- return 86 /* CommandResult.InvalidHeaderIndex */;
39822
+ return 87 /* CommandResult.InvalidHeaderIndex */;
39725
39823
  }
39726
39824
  return 0 /* CommandResult.Success */;
39727
39825
  }
@@ -39906,6 +40004,19 @@ class ImageProvider {
39906
40004
  }
39907
40005
  }
39908
40006
 
40007
+ class FocusableElement {
40008
+ constructor() {
40009
+ this.focusableElement = undefined;
40010
+ }
40011
+ setFocusableElement(element) {
40012
+ this.focusableElement = element;
40013
+ }
40014
+ focus() {
40015
+ var _a;
40016
+ (_a = this.focusableElement) === null || _a === void 0 ? void 0 : _a.focus();
40017
+ }
40018
+ }
40019
+
39909
40020
  const RIPPLE_KEY_FRAMES = [
39910
40021
  { transform: "scale(0)" },
39911
40022
  { transform: "scale(0.8)", offset: 0.33 },
@@ -41096,7 +41207,7 @@ const AddMergeInteractiveContent = {
41096
41207
  };
41097
41208
  function interactiveAddMerge(env, sheetId, target) {
41098
41209
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
41099
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
41210
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
41100
41211
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
41101
41212
  }
41102
41213
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -41881,6 +41992,7 @@ class Spreadsheet extends owl.Component {
41881
41992
  _t: Spreadsheet._t,
41882
41993
  clipboard: this.env.clipboard || instantiateClipboard(),
41883
41994
  startCellEdition: (content) => this.onGridComposerCellFocused(content),
41995
+ focusableElement: new FocusableElement(),
41884
41996
  });
41885
41997
  owl.useExternalListener(window, "resize", () => this.render(true));
41886
41998
  owl.useExternalListener(window, "beforeunload", this.unbindModelEvents.bind(this));
@@ -41979,17 +42091,18 @@ class Spreadsheet extends owl.Component {
41979
42091
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
41980
42092
  this.composer.topBarFocus = "contentFocus";
41981
42093
  this.composer.gridFocusMode = "inactive";
41982
- this.setComposerContent({ selection } || {});
42094
+ this.setComposerContent({ selection });
41983
42095
  }
41984
- onGridComposerContentFocused() {
42096
+ onGridComposerContentFocused(selection) {
41985
42097
  if (this.model.getters.isReadonly()) {
41986
42098
  return;
41987
42099
  }
41988
42100
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
41989
42101
  this.composer.topBarFocus = "inactive";
41990
42102
  this.composer.gridFocusMode = "contentFocus";
41991
- this.setComposerContent({});
42103
+ this.setComposerContent({ selection });
41992
42104
  }
42105
+ // TODO: either both are defined or none of them. change those args to an object
41993
42106
  onGridComposerCellFocused(content, selection) {
41994
42107
  if (this.model.getters.isReadonly()) {
41995
42108
  return;
@@ -43090,7 +43203,7 @@ class SelectionStreamProcessorImpl {
43090
43203
  */
43091
43204
  moveAnchorCell(direction, step = 1) {
43092
43205
  if (step !== "end" && step <= 0) {
43093
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
43206
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
43094
43207
  }
43095
43208
  const { col, row } = this.getNextAvailablePosition(direction, step);
43096
43209
  return this.selectCell(col, row);
@@ -43136,7 +43249,7 @@ class SelectionStreamProcessorImpl {
43136
43249
  */
43137
43250
  resizeAnchorZone(direction, step = 1) {
43138
43251
  if (step !== "end" && step <= 0) {
43139
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
43252
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
43140
43253
  }
43141
43254
  const sheetId = this.getters.getActiveSheetId();
43142
43255
  const anchor = this.anchor;
@@ -43965,12 +44078,7 @@ function addFormula(cell) {
43965
44078
  attrs.push(["t", "str"]);
43966
44079
  cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
43967
44080
  }
43968
- node = escapeXml /*xml*/ `
43969
- <f>
43970
- ${XlsxFormula}
43971
- </f>
43972
- ${cycle}
43973
- `;
44081
+ node = escapeXml /*xml*/ `<f> ${XlsxFormula} </f> ${cycle}`;
43974
44082
  return { attrs, node };
43975
44083
  }
43976
44084
  else {
@@ -44766,11 +44874,10 @@ function addRows(construct, data, sheet) {
44766
44874
  ({ attrs: additionalAttrs, node: cellNode } = addContent(cell.content, construct.sharedStrings, isTableHeader));
44767
44875
  }
44768
44876
  attributes.push(...additionalAttrs);
44769
- cellNodes.push(escapeXml /*xml*/ `
44770
- <c ${formatAttributes(attributes)}>
44771
- ${cellNode}
44772
- </c>
44773
- `);
44877
+ // prettier-ignore
44878
+ cellNodes.push(escapeXml /*xml*/ `<c ${formatAttributes(attributes)}>
44879
+ ${cellNode}
44880
+ </c>`);
44774
44881
  }
44775
44882
  }
44776
44883
  if (cellNodes.length || row.size !== DEFAULT_CELL_HEIGHT || row.isHidden) {
@@ -45174,10 +45281,10 @@ class Model extends EventBus {
45174
45281
  const command = { ...payload, type };
45175
45282
  let status = this.status;
45176
45283
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
45177
- return new DispatchResult(67 /* CommandResult.Readonly */);
45284
+ return new DispatchResult(68 /* CommandResult.Readonly */);
45178
45285
  }
45179
45286
  if (!this.session.canApplyOptimisticUpdate()) {
45180
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
45287
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
45181
45288
  }
45182
45289
  switch (status) {
45183
45290
  case 0 /* Status.Ready */:
@@ -45664,6 +45771,6 @@ exports.setTranslationMethod = setTranslationMethod;
45664
45771
  exports.tokenize = tokenize;
45665
45772
 
45666
45773
 
45667
- __info__.version = '16.2.28';
45668
- __info__.date = '2024-01-17T10:24:07.951Z';
45669
- __info__.hash = '16cee48';
45774
+ __info__.version = '16.2.31';
45775
+ __info__.date = '2024-02-09T13:05:40.161Z';
45776
+ __info__.hash = '2e76bdf';