@odoo/o-spreadsheet 16.3.22 → 16.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1742,6 +1742,9 @@ function parseFormat(formatString) {
1742
1742
  function formatValue(value, format) {
1743
1743
  switch (typeof value) {
1744
1744
  case "string":
1745
+ if (value.includes('\\"')) {
1746
+ return value.replace(/\\"/g, '"');
1747
+ }
1745
1748
  return value;
1746
1749
  case "boolean":
1747
1750
  return value ? "TRUE" : "FALSE";
@@ -2073,27 +2076,30 @@ function detectFormat(content) {
2073
2076
  }
2074
2077
  function createLargeNumberFormat(format, magnitude, postFix) {
2075
2078
  const internalFormat = parseFormat(format || "#,##0");
2076
- const largeNumberFormat = internalFormat
2077
- .map((formatPart) => {
2078
- if (formatPart.type === "NUMBER") {
2079
- return [
2080
- {
2081
- ...formatPart,
2082
- format: {
2083
- ...formatPart.format,
2084
- magnitude,
2085
- decimalPart: undefined,
2086
- },
2087
- },
2088
- {
2089
- type: "STRING",
2090
- format: postFix,
2091
- },
2092
- ];
2079
+ const largeNumberFormat = [];
2080
+ for (let i = 0; i < internalFormat.length; i++) {
2081
+ const formatPart = internalFormat[i];
2082
+ if (formatPart.type !== "NUMBER") {
2083
+ largeNumberFormat.push(formatPart);
2084
+ continue;
2093
2085
  }
2094
- return formatPart;
2095
- })
2096
- .flat();
2086
+ largeNumberFormat.push({
2087
+ ...formatPart,
2088
+ format: {
2089
+ ...formatPart.format,
2090
+ magnitude,
2091
+ decimalPart: undefined,
2092
+ },
2093
+ });
2094
+ largeNumberFormat.push({
2095
+ type: "STRING",
2096
+ format: postFix,
2097
+ });
2098
+ const nextFormatPart = internalFormat[i + 1];
2099
+ if (nextFormatPart?.type === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
2100
+ i++;
2101
+ }
2102
+ }
2097
2103
  return convertInternalFormatToFormat(largeNumberFormat);
2098
2104
  }
2099
2105
  function changeDecimalPlaces(format, step) {
@@ -4435,69 +4441,70 @@ var CommandResult;
4435
4441
  CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
4436
4442
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
4437
4443
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
4438
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
4439
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
4440
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
4441
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
4442
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
4443
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
4444
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
4445
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
4446
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
4447
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
4448
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
4449
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
4450
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
4451
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
4452
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
4453
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
4454
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
4455
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
4456
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
4457
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
4458
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
4459
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
4460
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
4461
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
4462
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
4463
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
4464
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
4465
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
4466
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
4467
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
4468
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
4469
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
4470
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
4471
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
4472
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
4473
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
4474
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
4475
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
4476
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
4477
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
4478
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
4479
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
4480
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
4481
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
4482
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
4483
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
4484
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
4485
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
4486
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
4487
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
4488
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
4489
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
4490
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
4491
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
4492
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
4493
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
4494
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4495
- CommandResult[CommandResult["MoreThanOneColumnSelected"] = 88] = "MoreThanOneColumnSelected";
4496
- CommandResult[CommandResult["EmptySplitSeparator"] = 89] = "EmptySplitSeparator";
4497
- CommandResult[CommandResult["SplitWillOverwriteContent"] = 90] = "SplitWillOverwriteContent";
4498
- CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 91] = "NoSplitSeparatorInSelection";
4499
- CommandResult[CommandResult["NoActiveSheet"] = 92] = "NoActiveSheet";
4500
- CommandResult[CommandResult["NoChanges"] = 93] = "NoChanges";
4444
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
4445
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
4446
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
4447
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
4448
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
4449
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
4450
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
4451
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
4452
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
4453
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
4454
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
4455
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
4456
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
4457
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
4458
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
4459
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
4460
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
4461
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
4462
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
4463
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
4464
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
4465
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
4466
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
4467
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
4468
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
4469
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
4470
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
4471
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
4472
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
4473
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
4474
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
4475
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
4476
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
4477
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
4478
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
4479
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
4480
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
4481
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
4482
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
4483
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
4484
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
4485
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
4486
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
4487
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
4488
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
4489
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
4490
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
4491
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
4492
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
4493
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
4494
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
4495
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
4496
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
4497
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
4498
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
4499
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
4500
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
4501
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
4502
+ CommandResult[CommandResult["MoreThanOneColumnSelected"] = 89] = "MoreThanOneColumnSelected";
4503
+ CommandResult[CommandResult["EmptySplitSeparator"] = 90] = "EmptySplitSeparator";
4504
+ CommandResult[CommandResult["SplitWillOverwriteContent"] = 91] = "SplitWillOverwriteContent";
4505
+ CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 92] = "NoSplitSeparatorInSelection";
4506
+ CommandResult[CommandResult["NoActiveSheet"] = 93] = "NoActiveSheet";
4507
+ CommandResult[CommandResult["NoChanges"] = 94] = "NoChanges";
4501
4508
  })(CommandResult || (CommandResult = {}));
4502
4509
 
4503
4510
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
@@ -6457,14 +6464,8 @@ function createDataSets(getters, dataSetsString, sheetId, dataSetsHaveTitle) {
6457
6464
  : undefined));
6458
6465
  }
6459
6466
  }
6460
- else if (zone.left === zone.right && zone.top === zone.bottom) {
6461
- // A single cell. If it's only the title, the dataset is not added.
6462
- if (!dataSetsHaveTitle) {
6463
- dataSets.push(createDataSet(getters, dataSetSheetId, zone, undefined));
6464
- }
6465
- }
6466
6467
  else {
6467
- /* 1 row or 1 column */
6468
+ /* 1 cell, 1 row or 1 column */
6468
6469
  dataSets.push(createDataSet(getters, dataSetSheetId, zone, dataSetsHaveTitle
6469
6470
  ? {
6470
6471
  top: zone.top,
@@ -6513,8 +6514,10 @@ function toExcelDataset(getters, ds) {
6513
6514
  }
6514
6515
  const dataRange = ds.dataRange.clone({ zone: dataZone });
6515
6516
  return {
6516
- label: ds.labelCell ? getters.getRangeString(ds.labelCell, "forceSheetReference") : undefined,
6517
- range: getters.getRangeString(dataRange, "forceSheetReference"),
6517
+ label: ds.labelCell
6518
+ ? getters.getRangeString(ds.labelCell, "forceSheetReference", true)
6519
+ : undefined,
6520
+ range: getters.getRangeString(dataRange, "forceSheetReference", true),
6518
6521
  };
6519
6522
  }
6520
6523
  function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
@@ -6527,7 +6530,7 @@ function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
6527
6530
  zone.top = zone.top + 1;
6528
6531
  }
6529
6532
  const range = labelRange.clone({ zone });
6530
- return getters.getRangeString(range, "forceSheetReference");
6533
+ return getters.getRangeString(range, "forceSheetReference", true);
6531
6534
  }
6532
6535
  /**
6533
6536
  * Transform a chart definition which supports dataSets (dataSets and LabelRange)
@@ -6593,11 +6596,11 @@ function checkDataset(definition) {
6593
6596
  if (definition.dataSets) {
6594
6597
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
6595
6598
  if (invalidRanges) {
6596
- return 32 /* CommandResult.InvalidDataSet */;
6599
+ return 33 /* CommandResult.InvalidDataSet */;
6597
6600
  }
6598
6601
  const zones = definition.dataSets.map(toUnboundedZone);
6599
6602
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
6600
- return 32 /* CommandResult.InvalidDataSet */;
6603
+ return 33 /* CommandResult.InvalidDataSet */;
6601
6604
  }
6602
6605
  }
6603
6606
  return 0 /* CommandResult.Success */;
@@ -6606,7 +6609,7 @@ function checkLabelRange(definition) {
6606
6609
  if (definition.labelRange) {
6607
6610
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
6608
6611
  if (invalidLabels) {
6609
- return 33 /* CommandResult.InvalidLabelRange */;
6612
+ return 34 /* CommandResult.InvalidLabelRange */;
6610
6613
  }
6611
6614
  }
6612
6615
  return 0 /* CommandResult.Success */;
@@ -6693,22 +6696,22 @@ function getChartPositionAtCenterOfViewport(getters, chartSize) {
6693
6696
  const CfTerms = {
6694
6697
  Errors: {
6695
6698
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
6696
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6697
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6698
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6699
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6700
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6701
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6702
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6703
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6704
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6705
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6706
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6707
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6708
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6709
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6710
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6711
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6699
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6700
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6701
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6702
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6703
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6704
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6705
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6706
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6707
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6708
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6709
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6710
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6711
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6712
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6713
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6714
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6712
6715
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
6713
6716
  Unexpected: _lt("The rule is invalid for an unknown reason"),
6714
6717
  },
@@ -6736,20 +6739,20 @@ const ChartTerms = {
6736
6739
  Errors: {
6737
6740
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
6738
6741
  // BASIC CHART ERRORS (LINE | BAR | PIE)
6739
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6740
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6742
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6743
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6741
6744
  // SCORECARD CHART ERRORS
6742
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6743
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6745
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6746
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6744
6747
  // GAUGE CHART ERRORS
6745
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6746
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6747
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6748
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6749
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6750
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6751
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6752
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6748
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6749
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6750
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6751
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6752
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6753
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6754
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6755
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6753
6756
  },
6754
6757
  };
6755
6758
  const CustomCurrencyTerms = {
@@ -6759,9 +6762,9 @@ const MergeErrorMessage = _lt("Merged cells are preventing this operation. Unmer
6759
6762
  const SplitToColumnsTerms = {
6760
6763
  Errors: {
6761
6764
  Unexpected: _lt("Cannot split the selection for an unknown reason"),
6762
- [91 /* CommandResult.NoSplitSeparatorInSelection */]: _lt("There is no match for the selected separator in the selection"),
6763
- [88 /* CommandResult.MoreThanOneColumnSelected */]: _lt("Only a selection from a single column can be split"),
6764
- [90 /* CommandResult.SplitWillOverwriteContent */]: _lt("Splitting will overwrite existing content"),
6765
+ [92 /* CommandResult.NoSplitSeparatorInSelection */]: _lt("There is no match for the selected separator in the selection"),
6766
+ [89 /* CommandResult.MoreThanOneColumnSelected */]: _lt("Only a selection from a single column can be split"),
6767
+ [91 /* CommandResult.SplitWillOverwriteContent */]: _lt("Splitting will overwrite existing content"),
6765
6768
  },
6766
6769
  };
6767
6770
 
@@ -7064,7 +7067,7 @@ class BarChart extends AbstractChart {
7064
7067
  return undefined;
7065
7068
  const dataSets = this.dataSets
7066
7069
  .map((ds) => toExcelDataset(this.getters, ds))
7067
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7070
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7068
7071
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7069
7072
  return {
7070
7073
  ...this.getDefinition(),
@@ -7165,7 +7168,7 @@ function createBarChartRuntime(chart, getters) {
7165
7168
 
7166
7169
  function isDataRangeValid(definition) {
7167
7170
  return definition.dataRange && !rangeReference.test(definition.dataRange)
7168
- ? 36 /* CommandResult.InvalidGaugeDataRange */
7171
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
7169
7172
  : 0 /* CommandResult.Success */;
7170
7173
  }
7171
7174
  function checkRangeLimits(check, batchValidations) {
@@ -7197,7 +7200,7 @@ function checkInflectionPointsValue(check, batchValidations) {
7197
7200
  function checkRangeMinBiggerThanRangeMax(definition) {
7198
7201
  if (definition.sectionRule) {
7199
7202
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
7200
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7203
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7201
7204
  }
7202
7205
  }
7203
7206
  return 0 /* CommandResult.Success */;
@@ -7206,9 +7209,9 @@ function checkEmpty(value, valueName) {
7206
7209
  if (value === "") {
7207
7210
  switch (valueName) {
7208
7211
  case "rangeMin":
7209
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
7212
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
7210
7213
  case "rangeMax":
7211
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
7214
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
7212
7215
  }
7213
7216
  }
7214
7217
  return 0 /* CommandResult.Success */;
@@ -7217,13 +7220,13 @@ function checkNaN(value, valueName) {
7217
7220
  if (isNaN(value)) {
7218
7221
  switch (valueName) {
7219
7222
  case "rangeMin":
7220
- return 38 /* CommandResult.GaugeRangeMinNaN */;
7223
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
7221
7224
  case "rangeMax":
7222
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
7225
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
7223
7226
  case "lowerInflectionPointValue":
7224
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
7227
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
7225
7228
  case "upperInflectionPointValue":
7226
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
7229
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
7227
7230
  }
7228
7231
  }
7229
7232
  return 0 /* CommandResult.Success */;
@@ -7648,7 +7651,7 @@ class LineChart extends AbstractChart {
7648
7651
  return undefined;
7649
7652
  const dataSets = this.dataSets
7650
7653
  .map((ds) => toExcelDataset(this.getters, ds))
7651
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7654
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7652
7655
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7653
7656
  return {
7654
7657
  ...this.getDefinition(),
@@ -7933,7 +7936,7 @@ class PieChart extends AbstractChart {
7933
7936
  return undefined;
7934
7937
  const dataSets = this.dataSets
7935
7938
  .map((ds) => toExcelDataset(this.getters, ds))
7936
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7939
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7937
7940
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7938
7941
  return {
7939
7942
  ...this.getDefinition(),
@@ -8013,12 +8016,12 @@ function createPieChartRuntime(chart, getters) {
8013
8016
 
8014
8017
  function checkKeyValue(definition) {
8015
8018
  return definition.keyValue && !rangeReference.test(definition.keyValue)
8016
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
8019
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
8017
8020
  : 0 /* CommandResult.Success */;
8018
8021
  }
8019
8022
  function checkBaseline(definition) {
8020
8023
  return definition.baseline && !rangeReference.test(definition.baseline)
8021
- ? 35 /* CommandResult.InvalidScorecardBaseline */
8024
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
8022
8025
  : 0 /* CommandResult.Success */;
8023
8026
  }
8024
8027
  class ScorecardChart extends AbstractChart {
@@ -8524,7 +8527,7 @@ const AddMergeInteractiveContent = {
8524
8527
  };
8525
8528
  function interactiveAddMerge(env, sheetId, target) {
8526
8529
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
8527
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
8530
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
8528
8531
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
8529
8532
  }
8530
8533
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -8774,7 +8777,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
8774
8777
  });
8775
8778
  }
8776
8779
  }
8777
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
8780
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
8778
8781
  const { col, row } = anchor;
8779
8782
  env.model.selection.selectZone({ cell: { col, row }, zone });
8780
8783
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -8797,13 +8800,13 @@ const AddFilterInteractiveContent = {
8797
8800
  };
8798
8801
  function interactiveAddFilter(env, sheetId, target) {
8799
8802
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
8800
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
8803
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
8801
8804
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
8802
8805
  }
8803
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
8806
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
8804
8807
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
8805
8808
  }
8806
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
8809
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
8807
8810
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
8808
8811
  }
8809
8812
  }
@@ -8825,7 +8828,7 @@ function handlePasteResult(env, result) {
8825
8828
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
8826
8829
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
8827
8830
  }
8828
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
8831
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
8829
8832
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
8830
8833
  }
8831
8834
  }
@@ -16983,7 +16986,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
16983
16986
  const sheetId = env.model.getters.getActiveSheetId();
16984
16987
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
16985
16988
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
16986
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
16989
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
16987
16990
  env.raiseError(MergeErrorMessage);
16988
16991
  }
16989
16992
  }
@@ -18006,10 +18009,10 @@ class LineBarPieConfigPanel extends Component {
18006
18009
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18007
18010
  }
18008
18011
  get isDatasetInvalid() {
18009
- return !!this.state.datasetDispatchResult?.isCancelledBecause(32 /* CommandResult.InvalidDataSet */);
18012
+ return !!this.state.datasetDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidDataSet */);
18010
18013
  }
18011
18014
  get isLabelInvalid() {
18012
- return !!this.state.labelsDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */);
18015
+ return !!this.state.labelsDispatchResult?.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */);
18013
18016
  }
18014
18017
  onUpdateDataSetsHaveTitle(ev) {
18015
18018
  this.props.updateChart(this.props.figureId, {
@@ -18451,7 +18454,7 @@ class GaugeChartConfigPanel extends Component {
18451
18454
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18452
18455
  }
18453
18456
  get isDataRangeInvalid() {
18454
- return !!this.state.dataRangeDispatchResult?.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */);
18457
+ return !!this.state.dataRangeDispatchResult?.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */);
18455
18458
  }
18456
18459
  onDataRangeChanged(ranges) {
18457
18460
  this.dataRange = ranges[0];
@@ -18525,25 +18528,25 @@ class GaugeChartDesignPanel extends Component {
18525
18528
  });
18526
18529
  }
18527
18530
  isRangeMinInvalid() {
18528
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */) ||
18529
- this.state.sectionRuleDispatchResult?.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */) ||
18530
- this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18531
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */) ||
18532
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */) ||
18533
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18531
18534
  }
18532
18535
  isRangeMaxInvalid() {
18533
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */) ||
18534
- this.state.sectionRuleDispatchResult?.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */) ||
18535
- this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18536
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */) ||
18537
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */) ||
18538
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18536
18539
  }
18537
18540
  // ---------------------------------------------------------------------------
18538
18541
  // COLOR_SECTION_TEMPLATE
18539
18542
  // ---------------------------------------------------------------------------
18540
18543
  get isLowerInflectionPointInvalid() {
18541
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */) ||
18542
- this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */));
18544
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */) ||
18545
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */));
18543
18546
  }
18544
18547
  get isUpperInflectionPointInvalid() {
18545
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */) ||
18546
- this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */));
18548
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */) ||
18549
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */));
18547
18550
  }
18548
18551
  updateInflectionPointValue(attr, ev) {
18549
18552
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -18651,10 +18654,10 @@ class ScorecardChartConfigPanel extends Component {
18651
18654
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18652
18655
  }
18653
18656
  get isKeyValueInvalid() {
18654
- return !!this.state.keyValueDispatchResult?.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */);
18657
+ return !!this.state.keyValueDispatchResult?.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */);
18655
18658
  }
18656
18659
  get isBaselineInvalid() {
18657
- return !!this.state.keyValueDispatchResult?.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */);
18660
+ return !!this.state.keyValueDispatchResult?.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */);
18658
18661
  }
18659
18662
  onKeyValueRangeChanged(ranges) {
18660
18663
  this.keyValue = ranges[0];
@@ -19514,10 +19517,10 @@ class ConditionalFormattingPanel extends Component {
19514
19517
  * Cell Is Rule
19515
19518
  ****************************************************************************/
19516
19519
  get isValue1Invalid() {
19517
- return !!this.state.errors?.includes(51 /* CommandResult.FirstArgMissing */);
19520
+ return !!this.state.errors?.includes(52 /* CommandResult.FirstArgMissing */);
19518
19521
  }
19519
19522
  get isValue2Invalid() {
19520
- return !!this.state.errors?.includes(52 /* CommandResult.SecondArgMissing */);
19523
+ return !!this.state.errors?.includes(53 /* CommandResult.SecondArgMissing */);
19521
19524
  }
19522
19525
  toggleStyle(tool) {
19523
19526
  const style = this.state.rules.cellIs.style;
@@ -19534,17 +19537,17 @@ class ConditionalFormattingPanel extends Component {
19534
19537
  isValueInvalid(threshold) {
19535
19538
  switch (threshold) {
19536
19539
  case "minimum":
19537
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
19538
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
19539
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
19540
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
19540
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
19541
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
19542
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
19543
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
19541
19544
  case "midpoint":
19542
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
19543
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
19544
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
19545
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
19546
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
19547
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
19545
19548
  case "maximum":
19546
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
19547
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
19549
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
19550
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
19548
19551
  default:
19549
19552
  return false;
19550
19553
  }
@@ -19592,13 +19595,13 @@ class ConditionalFormattingPanel extends Component {
19592
19595
  isInflectionPointInvalid(inflectionPoint) {
19593
19596
  switch (inflectionPoint) {
19594
19597
  case "lowerInflectionPoint":
19595
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
19596
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
19597
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
19598
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
19599
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
19600
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
19598
19601
  case "upperInflectionPoint":
19599
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
19600
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
19601
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
19602
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
19603
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
19604
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
19602
19605
  default:
19603
19606
  return true;
19604
19607
  }
@@ -19909,7 +19912,7 @@ const SplitToColumnsInteractiveContent = {
19909
19912
  };
19910
19913
  function interactiveSplitToColumns(env, separator, addNewColumns) {
19911
19914
  let result = env.model.dispatch("SPLIT_TEXT_INTO_COLUMNS", { separator, addNewColumns });
19912
- if (result.isCancelledBecause(90 /* CommandResult.SplitWillOverwriteContent */)) {
19915
+ if (result.isCancelledBecause(91 /* CommandResult.SplitWillOverwriteContent */)) {
19913
19916
  env.askConfirmation(SplitToColumnsInteractiveContent.SplitIsDestructive, () => {
19914
19917
  result = env.model.dispatch("SPLIT_TEXT_INTO_COLUMNS", {
19915
19918
  separator,
@@ -19972,8 +19975,8 @@ class SplitIntoColumnsPanel extends Component {
19972
19975
  const errors = new Set();
19973
19976
  for (const reason of cancelledReasons) {
19974
19977
  switch (reason) {
19975
- case 90 /* CommandResult.SplitWillOverwriteContent */:
19976
- case 89 /* CommandResult.EmptySplitSeparator */:
19978
+ case 91 /* CommandResult.SplitWillOverwriteContent */:
19979
+ case 90 /* CommandResult.EmptySplitSeparator */:
19977
19980
  break;
19978
19981
  default:
19979
19982
  errors.add(SplitToColumnsTerms.Errors[reason] || SplitToColumnsTerms.Errors.Unexpected);
@@ -19988,8 +19991,8 @@ class SplitIntoColumnsPanel extends Component {
19988
19991
  addNewColumns: this.state.addNewColumns,
19989
19992
  force: false,
19990
19993
  }).reasons;
19991
- if (cancelledReasons.includes(90 /* CommandResult.SplitWillOverwriteContent */)) {
19992
- warnings.push(SplitToColumnsTerms.Errors[90 /* CommandResult.SplitWillOverwriteContent */]);
19994
+ if (cancelledReasons.includes(91 /* CommandResult.SplitWillOverwriteContent */)) {
19995
+ warnings.push(SplitToColumnsTerms.Errors[91 /* CommandResult.SplitWillOverwriteContent */]);
19993
19996
  }
19994
19997
  return warnings;
19995
19998
  }
@@ -20980,6 +20983,7 @@ class Composer extends Component {
20980
20983
  static components = { TextValueProvider, FunctionDescriptionProvider };
20981
20984
  static defaultProps = {
20982
20985
  inputStyle: "",
20986
+ isDefaultFocus: false,
20983
20987
  };
20984
20988
  composerRef = useRef("o_composer");
20985
20989
  contentHelper = new ContentEditableHelper(this.composerRef.el);
@@ -21037,13 +21041,13 @@ class Composer extends Component {
21037
21041
  setup() {
21038
21042
  onMounted(() => {
21039
21043
  const el = this.composerRef.el;
21044
+ if (this.props.isDefaultFocus) {
21045
+ this.env.focusableElement.setFocusableElement(el);
21046
+ }
21040
21047
  this.contentHelper.updateEl(el);
21041
21048
  this.processContent();
21042
21049
  this.contentHelper.scrollSelectionIntoView();
21043
21050
  });
21044
- onWillUnmount(() => {
21045
- this.props.onComposerUnmounted?.();
21046
- });
21047
21051
  onPatched(() => {
21048
21052
  if (!this.isKeyStillDown) {
21049
21053
  this.processContent();
@@ -21054,7 +21058,8 @@ class Composer extends Component {
21054
21058
  // Handlers
21055
21059
  // ---------------------------------------------------------------------------
21056
21060
  processArrowKeys(ev) {
21057
- if (this.env.model.getters.isSelectingForComposer()) {
21061
+ if (this.env.model.getters.isSelectingForComposer() ||
21062
+ this.env.model.getters.getEditionMode() === "inactive") {
21058
21063
  this.functionDescriptionState.showDescription = false;
21059
21064
  // Prevent the default content editable behavior which moves the cursor
21060
21065
  ev.preventDefault();
@@ -21094,21 +21099,23 @@ class Composer extends Component {
21094
21099
  processTabKey(ev) {
21095
21100
  ev.preventDefault();
21096
21101
  ev.stopPropagation();
21097
- if (this.autoCompleteState.showProvider) {
21098
- const autoCompleteValue = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;
21099
- if (autoCompleteValue) {
21100
- this.autoComplete(autoCompleteValue);
21101
- return;
21102
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
21103
+ if (this.autoCompleteState.showProvider) {
21104
+ const autoCompleteValue = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;
21105
+ if (autoCompleteValue) {
21106
+ this.autoComplete(autoCompleteValue);
21107
+ return;
21108
+ }
21102
21109
  }
21103
- }
21104
- else {
21105
- // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
21106
- // we can't let the model think that it is for a ref selection.
21107
- // todo: check if this can be removed someday
21108
- this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21110
+ else {
21111
+ // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
21112
+ // we can't let the model think that it is for a ref selection.
21113
+ // todo: check if this can be removed someday
21114
+ this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21115
+ }
21116
+ this.env.model.dispatch("STOP_EDITION");
21109
21117
  }
21110
21118
  const direction = ev.shiftKey ? "left" : "right";
21111
- this.env.model.dispatch("STOP_EDITION");
21112
21119
  this.env.model.selection.moveAnchorCell(direction, 1);
21113
21120
  }
21114
21121
  processEnterKey(ev) {
@@ -21152,6 +21159,9 @@ class Composer extends Component {
21152
21159
  this.compositionActive = false;
21153
21160
  }
21154
21161
  onKeydown(ev) {
21162
+ if (this.env.model.getters.getEditionMode() === "inactive") {
21163
+ return;
21164
+ }
21155
21165
  let handler = this.keyMapping[ev.key];
21156
21166
  if (handler) {
21157
21167
  handler.call(this, ev);
@@ -21162,22 +21172,44 @@ class Composer extends Component {
21162
21172
  }
21163
21173
  }
21164
21174
  updateCursorIfNeeded() {
21165
- if (!this.env.model.getters.isSelectingForComposer()) {
21175
+ const moveCursor = !this.env.model.getters.isSelectingForComposer() &&
21176
+ !(this.env.model.getters.getEditionMode() === "inactive");
21177
+ if (moveCursor) {
21166
21178
  const { start, end } = this.contentHelper.getCurrentSelection();
21167
21179
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
21168
21180
  this.isKeyStillDown = true;
21169
21181
  }
21170
21182
  }
21183
+ onPaste(ev) {
21184
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
21185
+ ev.stopPropagation();
21186
+ }
21187
+ }
21171
21188
  /*
21172
21189
  * Triggered automatically by the content-editable between the keydown and key up
21173
21190
  * */
21174
- onInput() {
21175
- if (this.props.focus === "inactive" || !this.shouldProcessInputEvents) {
21191
+ onInput(ev) {
21192
+ if (!this.shouldProcessInputEvents) {
21176
21193
  return;
21177
21194
  }
21195
+ if (ev.inputType === "insertFromPaste" &&
21196
+ this.env.model.getters.getEditionMode() === "inactive") {
21197
+ return;
21198
+ }
21199
+ ev.stopPropagation();
21200
+ let content;
21201
+ if (this.env.model.getters.getEditionMode() === "inactive") {
21202
+ content = ev.data || "";
21203
+ }
21204
+ else {
21205
+ content = this.contentHelper.getText();
21206
+ }
21207
+ if (this.props.focus === "inactive") {
21208
+ return this.props.onComposerCellFocused?.(content);
21209
+ }
21178
21210
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21179
21211
  this.env.model.dispatch("SET_CURRENT_CONTENT", {
21180
- content: this.contentHelper.getText(),
21212
+ content,
21181
21213
  selection: this.contentHelper.getCurrentSelection(),
21182
21214
  });
21183
21215
  }
@@ -21248,9 +21280,8 @@ class Composer extends Component {
21248
21280
  }
21249
21281
  const newSelection = this.contentHelper.getCurrentSelection();
21250
21282
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21251
- if (this.props.focus === "inactive") {
21252
- this.props.onComposerContentFocused(newSelection);
21253
- }
21283
+ this.props.onComposerContentFocused();
21284
+ if (this.props.focus === "inactive") ;
21254
21285
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", newSelection);
21255
21286
  this.processTokenAtCursor();
21256
21287
  }
@@ -21394,7 +21425,7 @@ class Composer extends Component {
21394
21425
  const highlights = this.env.model.getters.getHighlights();
21395
21426
  const refSheet = sheetName
21396
21427
  ? this.env.model.getters.getSheetIdByName(sheetName)
21397
- : this.env.model.getters.getCurrentEditedCell().sheetId;
21428
+ : this.env.model.getters.getCurrentEditedCell()?.sheetId;
21398
21429
  const highlight = highlights.find((highlight) => {
21399
21430
  if (highlight.sheetId !== refSheet)
21400
21431
  return false;
@@ -21471,12 +21502,13 @@ class Composer extends Component {
21471
21502
  }
21472
21503
  }
21473
21504
  Composer.props = {
21474
- focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21475
- onComposerContentFocused: Function,
21476
21505
  inputStyle: { type: String, optional: true },
21477
21506
  rect: { type: Object, optional: true },
21478
21507
  delimitation: { type: Object, optional: true },
21479
- onComposerUnmounted: { type: Function, optional: true },
21508
+ focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21509
+ onComposerCellFocused: { type: Function, optional: true },
21510
+ onComposerContentFocused: Function,
21511
+ isDefaultFocus: { type: Boolean, optional: true },
21480
21512
  };
21481
21513
 
21482
21514
  const COMPOSER_BORDER_WIDTH = 3 * 0.4 * window.devicePixelRatio || 1;
@@ -21510,51 +21542,26 @@ css /* scss */ `
21510
21542
  class GridComposer extends Component {
21511
21543
  static template = "o-spreadsheet-GridComposer";
21512
21544
  static components = { Composer };
21513
- gridComposerRef;
21514
- zone;
21515
- rect;
21545
+ // TODORAR see if we can keep it undefined
21546
+ rect = this.defaultRect;
21547
+ isEditing = false;
21516
21548
  isCellReferenceVisible;
21517
- composerState;
21549
+ get defaultRect() {
21550
+ return { x: 0, y: 0, width: 0, height: 0 };
21551
+ }
21518
21552
  setup() {
21519
- this.gridComposerRef = useRef("gridComposer");
21520
- this.composerState = useState({
21521
- rect: undefined,
21522
- delimitation: undefined,
21523
- });
21524
- const { sheetId, col, row } = this.env.model.getters.getActivePosition();
21525
- this.zone = this.env.model.getters.expandZone(sheetId, positionToZone({ col, row }));
21526
- this.rect = this.env.model.getters.getVisibleRect(this.zone);
21527
- this.isCellReferenceVisible = false;
21528
- onMounted(() => {
21529
- const el = this.gridComposerRef.el;
21530
- this.composerState.rect = {
21531
- x: this.rect.x,
21532
- y: this.rect.y,
21533
- width: el.clientWidth,
21534
- height: el.clientHeight,
21535
- };
21536
- this.composerState.delimitation = {
21537
- width: el.parentElement.clientWidth,
21538
- height: el.parentElement.clientHeight,
21539
- };
21540
- });
21541
21553
  onWillUpdateProps(() => {
21542
- if (this.isCellReferenceVisible) {
21543
- return;
21544
- }
21545
- const sheetId = this.env.model.getters.getActiveSheetId();
21546
- const zone = this.env.model.getters.getSelectedZone();
21547
- const rect = this.env.model.getters.getVisibleRect(zone);
21548
- if (!deepEquals(rect, this.rect) ||
21549
- sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
21550
- this.isCellReferenceVisible = true;
21551
- }
21554
+ this.updateComponentPosition();
21555
+ this.updateCellReferenceVisibility();
21552
21556
  });
21553
21557
  }
21554
21558
  get shouldDisplayCellReference() {
21555
21559
  return this.isCellReferenceVisible;
21556
21560
  }
21557
21561
  get cellReference() {
21562
+ if (!this.env.model.getters.getCurrentEditedCell()) {
21563
+ return "";
21564
+ }
21558
21565
  const { col, row, sheetId } = this.env.model.getters.getCurrentEditedCell();
21559
21566
  const prefixSheet = sheetId !== this.env.model.getters.getActiveSheetId();
21560
21567
  return `${prefixSheet ? getCanonicalSheetName(this.env.model.getters.getSheetName(sheetId)) + "!" : ""}${toXC(col, row)}`;
@@ -21566,7 +21573,27 @@ class GridComposer extends Component {
21566
21573
  top: `${top - GRID_CELL_REFERENCE_TOP_OFFSET}px`,
21567
21574
  });
21568
21575
  }
21576
+ get composerProps() {
21577
+ const { width, height } = this.env.model.getters.getSheetViewDimensionWithHeaders();
21578
+ return {
21579
+ rect: { ...this.rect },
21580
+ delimitation: {
21581
+ width,
21582
+ height,
21583
+ },
21584
+ focus: this.props.focus,
21585
+ isDefaultFocus: true,
21586
+ onComposerContentFocused: this.props.onComposerContentFocused,
21587
+ onComposerCellFocused: this.props.onComposerCellFocused,
21588
+ };
21589
+ }
21569
21590
  get containerStyle() {
21591
+ if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
21592
+ return `
21593
+ position: absolute;
21594
+ z-index: -1000;
21595
+ `;
21596
+ }
21570
21597
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
21571
21598
  const cell = this.env.model.getters.getActiveCell();
21572
21599
  const position = this.env.model.getters.getActivePosition();
@@ -21586,6 +21613,8 @@ class GridComposer extends Component {
21586
21613
  if (!isFormula) {
21587
21614
  textAlign = style.align || cell.defaultAlign;
21588
21615
  }
21616
+ const maxHeight = this.props.gridDims.height - this.rect.y;
21617
+ const maxWidth = this.props.gridDims.width - this.rect.x;
21589
21618
  /**
21590
21619
  * min-size is on the container, not the composer element, because we want to have the same size as the cell by default,
21591
21620
  * including all the paddings/margins of the composer
@@ -21597,6 +21626,8 @@ class GridComposer extends Component {
21597
21626
  top: `${top}px`,
21598
21627
  "min-width": `${width + 1}px`,
21599
21628
  "min-height": `${height + 1}px`,
21629
+ "max-width": `${maxWidth}px`,
21630
+ "max-height": `${maxHeight}px`,
21600
21631
  background,
21601
21632
  color,
21602
21633
  "font-size": `${fontSizeInPixels(fontSize)}px`,
@@ -21606,20 +21637,38 @@ class GridComposer extends Component {
21606
21637
  "text-align": textAlign,
21607
21638
  });
21608
21639
  }
21609
- get composerStyle() {
21610
- const maxHeight = this.props.gridDims.height - this.rect.y;
21611
- const maxWidth = this.props.gridDims.width - this.rect.x;
21612
- return cssPropertiesToCss({
21613
- "max-width": `${maxWidth}px`,
21614
- "max-height": `${maxHeight}px`,
21615
- });
21640
+ updateComponentPosition() {
21641
+ const isEditing = this.env.model.getters.getEditionMode() !== "inactive";
21642
+ if (this.isEditing !== isEditing) {
21643
+ this.isEditing = isEditing;
21644
+ if (!isEditing) {
21645
+ this.rect = this.defaultRect;
21646
+ this.env.focusableElement.focus();
21647
+ return;
21648
+ }
21649
+ const position = this.env.model.getters.getActivePosition();
21650
+ const zone = this.env.model.getters.expandZone(position.sheetId, positionToZone(position));
21651
+ this.rect = this.env.model.getters.getVisibleRect(zone);
21652
+ }
21653
+ }
21654
+ updateCellReferenceVisibility() {
21655
+ if (this.isCellReferenceVisible || this.env.model.getters.getEditionMode() === "inactive") {
21656
+ return;
21657
+ }
21658
+ const sheetId = this.env.model.getters.getActiveSheetId();
21659
+ const zone = this.env.model.getters.getSelectedZone();
21660
+ const rect = this.env.model.getters.getVisibleRect(zone);
21661
+ if (!deepEquals(rect, this.rect) ||
21662
+ sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
21663
+ this.isCellReferenceVisible = true;
21664
+ }
21616
21665
  }
21617
21666
  }
21618
21667
  GridComposer.props = {
21619
21668
  focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21620
- onComposerUnmounted: Function,
21621
21669
  onComposerContentFocused: Function,
21622
21670
  gridDims: Object,
21671
+ onComposerCellFocused: Function,
21623
21672
  };
21624
21673
 
21625
21674
  const CSS$1 = css /* scss */ `
@@ -22488,7 +22537,6 @@ class GridOverlay extends Component {
22488
22537
  this.props.onCellDoubleClicked(col, row);
22489
22538
  }
22490
22539
  onContextMenu(ev) {
22491
- ev.preventDefault();
22492
22540
  const [col, row] = this.getCartesianCoordinates(ev);
22493
22541
  this.props.onCellRightClicked(col, row, { x: ev.clientX, y: ev.clientY });
22494
22542
  }
@@ -23582,7 +23630,6 @@ class Grid extends Component {
23582
23630
  HEADER_WIDTH = HEADER_WIDTH;
23583
23631
  menuState;
23584
23632
  gridRef;
23585
- hiddenInput;
23586
23633
  onMouseWheel;
23587
23634
  canvasPosition;
23588
23635
  hoveredCell;
@@ -23593,17 +23640,16 @@ class Grid extends Component {
23593
23640
  menuItems: [],
23594
23641
  });
23595
23642
  this.gridRef = useRef("grid");
23596
- this.hiddenInput = useRef("hiddenInput");
23597
23643
  this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
23598
23644
  this.hoveredCell = useState({ col: undefined, row: undefined });
23599
23645
  useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
23600
23646
  useExternalListener(document.body, "cut", this.copy.bind(this, true));
23601
23647
  useExternalListener(document.body, "copy", this.copy.bind(this, false));
23602
23648
  useExternalListener(document.body, "paste", this.paste);
23603
- onMounted(() => this.focus());
23604
- this.props.exposeFocus(() => this.focus());
23649
+ onMounted(() => this.focusDefaultElement());
23650
+ this.props.exposeFocus(() => this.focusDefaultElement());
23605
23651
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimensionWithHeaders());
23606
- useEffect(() => this.focus(), () => [this.env.model.getters.getActiveSheetId()]);
23652
+ useEffect(() => this.focusDefaultElement(), () => [this.env.model.getters.getActiveSheetId()]);
23607
23653
  this.onMouseWheel = useWheelHandler((deltaX, deltaY) => {
23608
23654
  this.moveCanvas(deltaX, deltaY);
23609
23655
  this.hoveredCell.col = undefined;
@@ -23626,7 +23672,7 @@ class Grid extends Component {
23626
23672
  if (this.env.model.getters.hasOpenedPopover()) {
23627
23673
  this.closeOpenedPopover();
23628
23674
  }
23629
- this.focus();
23675
+ this.focusDefaultElement();
23630
23676
  }
23631
23677
  // this map will handle most of the actions that should happen on key down. The arrow keys are managed in the key
23632
23678
  // down itself
@@ -23796,10 +23842,10 @@ class Grid extends Component {
23796
23842
  PAGEUP: () => this.env.model.dispatch("SHIFT_VIEWPORT_UP"),
23797
23843
  "CTRL+K": () => INSERT_LINK(this.env),
23798
23844
  };
23799
- focus() {
23845
+ focusDefaultElement() {
23800
23846
  if (!this.env.model.getters.getSelectedFigureId() &&
23801
23847
  this.env.model.getters.getEditionMode() === "inactive") {
23802
- this.hiddenInput.el?.focus();
23848
+ this.env.focusableElement.focus();
23803
23849
  }
23804
23850
  }
23805
23851
  get gridEl() {
@@ -23943,19 +23989,6 @@ class Grid extends Component {
23943
23989
  return;
23944
23990
  }
23945
23991
  }
23946
- onInput(ev) {
23947
- // the user meant to paste in the sheet, not open the composer with the pasted content
23948
- if (!ev.isComposing && ev.inputType === "insertFromPaste") {
23949
- return;
23950
- }
23951
- if (ev.data) {
23952
- // if the user types a character on the grid, it means he wants to start composing the selected cell with that
23953
- // character
23954
- ev.preventDefault();
23955
- ev.stopPropagation();
23956
- this.props.onGridComposerCellFocused(ev.data);
23957
- }
23958
- }
23959
23992
  // ---------------------------------------------------------------------------
23960
23993
  // Context Menu
23961
23994
  // ---------------------------------------------------------------------------
@@ -24065,7 +24098,7 @@ class Grid extends Component {
24065
24098
  }
24066
24099
  closeMenu() {
24067
24100
  this.menuState.isOpen = false;
24068
- this.focus();
24101
+ this.focusDefaultElement();
24069
24102
  }
24070
24103
  }
24071
24104
  Grid.props = {
@@ -28725,6 +28758,31 @@ const MIGRATIONS = [
28725
28758
  return data;
28726
28759
  },
28727
28760
  },
28761
+ {
28762
+ description: "Fix datafilter duplication",
28763
+ from: 12,
28764
+ to: 12.5,
28765
+ applyMigration(data) {
28766
+ for (let sheet of data.sheets || []) {
28767
+ let knownDataFilterZones = [];
28768
+ for (let filterTable of sheet.filterTables || []) {
28769
+ const zone = toZone(filterTable.range);
28770
+ // See commit message for the details
28771
+ const intersectZoneIndex = knownDataFilterZones.findIndex((knownZone) => overlap(knownZone, zone));
28772
+ if (intersectZoneIndex !== -1) {
28773
+ knownDataFilterZones[intersectZoneIndex] = zone;
28774
+ }
28775
+ else {
28776
+ knownDataFilterZones.push(zone);
28777
+ }
28778
+ }
28779
+ sheet.filterTables = knownDataFilterZones.map((zone) => ({
28780
+ range: zoneToXc(zone),
28781
+ }));
28782
+ }
28783
+ return data;
28784
+ },
28785
+ },
28728
28786
  {
28729
28787
  description: "Change Border description structure",
28730
28788
  from: 12,
@@ -29515,7 +29573,7 @@ class BordersPlugin extends CorePlugin {
29515
29573
  const currentBorder = this.getCellBorder(cmd);
29516
29574
  const areAllNewBordersUndefined = !cmd.border?.bottom && !cmd.border?.left && !cmd.border?.right && !cmd.border?.top;
29517
29575
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
29518
- return 93 /* CommandResult.NoChanges */;
29576
+ return 94 /* CommandResult.NoChanges */;
29519
29577
  }
29520
29578
  return 0 /* CommandResult.Success */;
29521
29579
  }
@@ -29794,13 +29852,13 @@ class CellPlugin extends CorePlugin {
29794
29852
  /*
29795
29853
  * Reconstructs the original formula string based on a normalized form and its dependencies
29796
29854
  */
29797
- buildFormulaContent(sheetId, cell, dependencies) {
29855
+ buildFormulaContent(sheetId, cell, dependencies, useFixedZone = false) {
29798
29856
  const ranges = dependencies || cell.dependencies;
29799
29857
  let rangeIndex = 0;
29800
29858
  return concat(cell.compiledFormula.tokens.map((token) => {
29801
29859
  if (token.type === "REFERENCE") {
29802
29860
  const range = ranges[rangeIndex++];
29803
- return this.getters.getRangeString(range, sheetId);
29861
+ return this.getters.getRangeString(range, sheetId, useFixedZone);
29804
29862
  }
29805
29863
  return token.value;
29806
29864
  }));
@@ -30037,9 +30095,9 @@ class CellPlugin extends CorePlugin {
30037
30095
  checkUselessClearCell(cmd) {
30038
30096
  const cell = this.getters.getCell(cmd);
30039
30097
  if (!cell)
30040
- return 93 /* CommandResult.NoChanges */;
30098
+ return 94 /* CommandResult.NoChanges */;
30041
30099
  if (!cell.content && !cell.style && !cell.format) {
30042
- return 93 /* CommandResult.NoChanges */;
30100
+ return 94 /* CommandResult.NoChanges */;
30043
30101
  }
30044
30102
  return 0 /* CommandResult.Success */;
30045
30103
  }
@@ -30239,13 +30297,13 @@ class ChartPlugin extends CorePlugin {
30239
30297
  }
30240
30298
  checkChartDuplicate(cmd) {
30241
30299
  return this.getters.getFigureSheetId(cmd.id)
30242
- ? 84 /* CommandResult.DuplicatedChartId */
30300
+ ? 85 /* CommandResult.DuplicatedChartId */
30243
30301
  : 0 /* CommandResult.Success */;
30244
30302
  }
30245
30303
  checkChartExists(cmd) {
30246
30304
  return this.getters.getFigureSheetId(cmd.id)
30247
30305
  ? 0 /* CommandResult.Success */
30248
- : 85 /* CommandResult.ChartDoesNotExist */;
30306
+ : 86 /* CommandResult.ChartDoesNotExist */;
30249
30307
  }
30250
30308
  }
30251
30309
 
@@ -30350,7 +30408,13 @@ class ConditionalFormatPlugin extends CorePlugin {
30350
30408
  }
30351
30409
  }
30352
30410
  exportForExcel(data) {
30353
- this.export(data);
30411
+ if (data.sheets) {
30412
+ for (let sheet of data.sheets) {
30413
+ if (this.cfRules[sheet.id]) {
30414
+ sheet.conditionalFormats = this.cfRules[sheet.id].map((rule) => this.mapToConditionalFormat(sheet.id, rule, { useFixedReference: true }));
30415
+ }
30416
+ }
30417
+ }
30354
30418
  }
30355
30419
  // ---------------------------------------------------------------------------
30356
30420
  // Getters
@@ -30399,11 +30463,11 @@ class ConditionalFormatPlugin extends CorePlugin {
30399
30463
  // ---------------------------------------------------------------------------
30400
30464
  // Private
30401
30465
  // ---------------------------------------------------------------------------
30402
- mapToConditionalFormat(sheetId, cf) {
30466
+ mapToConditionalFormat(sheetId, cf, options = { useFixedReference: false }) {
30403
30467
  return {
30404
30468
  ...cf,
30405
30469
  ranges: cf.ranges.map((range) => {
30406
- return this.getters.getRangeString(range, sheetId);
30470
+ return this.getters.getRangeString(range, sheetId, options.useFixedReference);
30407
30471
  }),
30408
30472
  };
30409
30473
  }
@@ -30436,10 +30500,10 @@ class ConditionalFormatPlugin extends CorePlugin {
30436
30500
  return 27 /* CommandResult.InvalidSheetId */;
30437
30501
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
30438
30502
  if (ruleIndex === -1)
30439
- return 71 /* CommandResult.InvalidConditionalFormatId */;
30503
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
30440
30504
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
30441
30505
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
30442
- return 71 /* CommandResult.InvalidConditionalFormatId */;
30506
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
30443
30507
  }
30444
30508
  return 0 /* CommandResult.Success */;
30445
30509
  }
@@ -30480,10 +30544,10 @@ class ConditionalFormatPlugin extends CorePlugin {
30480
30544
  const errors = [];
30481
30545
  const isEmpty = (value) => value === undefined || value === "";
30482
30546
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
30483
- errors.push(51 /* CommandResult.FirstArgMissing */);
30547
+ errors.push(52 /* CommandResult.FirstArgMissing */);
30484
30548
  }
30485
30549
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
30486
- errors.push(52 /* CommandResult.SecondArgMissing */);
30550
+ errors.push(53 /* CommandResult.SecondArgMissing */);
30487
30551
  }
30488
30552
  return errors.length ? errors : 0 /* CommandResult.Success */;
30489
30553
  }
@@ -30495,15 +30559,15 @@ class ConditionalFormatPlugin extends CorePlugin {
30495
30559
  (threshold.value === "" || isNaN(threshold.value))) {
30496
30560
  switch (thresholdName) {
30497
30561
  case "min":
30498
- return 53 /* CommandResult.MinNaN */;
30562
+ return 54 /* CommandResult.MinNaN */;
30499
30563
  case "max":
30500
- return 55 /* CommandResult.MaxNaN */;
30564
+ return 56 /* CommandResult.MaxNaN */;
30501
30565
  case "mid":
30502
- return 54 /* CommandResult.MidNaN */;
30566
+ return 55 /* CommandResult.MidNaN */;
30503
30567
  case "upperInflectionPoint":
30504
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
30568
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
30505
30569
  case "lowerInflectionPoint":
30506
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
30570
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
30507
30571
  }
30508
30572
  }
30509
30573
  return 0 /* CommandResult.Success */;
@@ -30517,15 +30581,15 @@ class ConditionalFormatPlugin extends CorePlugin {
30517
30581
  catch (error) {
30518
30582
  switch (thresholdName) {
30519
30583
  case "min":
30520
- return 58 /* CommandResult.MinInvalidFormula */;
30584
+ return 59 /* CommandResult.MinInvalidFormula */;
30521
30585
  case "max":
30522
- return 60 /* CommandResult.MaxInvalidFormula */;
30586
+ return 61 /* CommandResult.MaxInvalidFormula */;
30523
30587
  case "mid":
30524
- return 59 /* CommandResult.MidInvalidFormula */;
30588
+ return 60 /* CommandResult.MidInvalidFormula */;
30525
30589
  case "upperInflectionPoint":
30526
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
30590
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
30527
30591
  case "lowerInflectionPoint":
30528
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
30592
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
30529
30593
  }
30530
30594
  }
30531
30595
  return 0 /* CommandResult.Success */;
@@ -30542,7 +30606,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30542
30606
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
30543
30607
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
30544
30608
  Number(minValue) > Number(maxValue)) {
30545
- return 48 /* CommandResult.LowerBiggerThanUpper */;
30609
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
30546
30610
  }
30547
30611
  return 0 /* CommandResult.Success */;
30548
30612
  }
@@ -30552,7 +30616,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30552
30616
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
30553
30617
  rule.minimum.type === rule.maximum.type &&
30554
30618
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
30555
- return 47 /* CommandResult.MinBiggerThanMax */;
30619
+ return 48 /* CommandResult.MinBiggerThanMax */;
30556
30620
  }
30557
30621
  return 0 /* CommandResult.Success */;
30558
30622
  }
@@ -30563,7 +30627,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30563
30627
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
30564
30628
  rule.midpoint.type === rule.maximum.type &&
30565
30629
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
30566
- return 49 /* CommandResult.MidBiggerThanMax */;
30630
+ return 50 /* CommandResult.MidBiggerThanMax */;
30567
30631
  }
30568
30632
  return 0 /* CommandResult.Success */;
30569
30633
  }
@@ -30574,7 +30638,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30574
30638
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
30575
30639
  rule.minimum.type === rule.midpoint.type &&
30576
30640
  stringToNumber(minValue) >= stringToNumber(midValue)) {
30577
- return 50 /* CommandResult.MinBiggerThanMid */;
30641
+ return 51 /* CommandResult.MinBiggerThanMid */;
30578
30642
  }
30579
30643
  return 0 /* CommandResult.Success */;
30580
30644
  }
@@ -30704,13 +30768,13 @@ class FigurePlugin extends CorePlugin {
30704
30768
  }
30705
30769
  checkFigureExists(sheetId, figureId) {
30706
30770
  if (this.figures[sheetId]?.[figureId] === undefined) {
30707
- return 70 /* CommandResult.FigureDoesNotExist */;
30771
+ return 71 /* CommandResult.FigureDoesNotExist */;
30708
30772
  }
30709
30773
  return 0 /* CommandResult.Success */;
30710
30774
  }
30711
30775
  checkFigureDuplicate(figureId) {
30712
30776
  if (Object.values(this.figures).find((sheet) => sheet?.[figureId])) {
30713
- return 82 /* CommandResult.DuplicatedFigureId */;
30777
+ return 83 /* CommandResult.DuplicatedFigureId */;
30714
30778
  }
30715
30779
  return 0 /* CommandResult.Success */;
30716
30780
  }
@@ -30820,12 +30884,12 @@ class FiltersPlugin extends CorePlugin {
30820
30884
  switch (cmd.type) {
30821
30885
  case "CREATE_FILTER_TABLE":
30822
30886
  if (!areZonesContinuous(...cmd.target)) {
30823
- return 81 /* CommandResult.NonContinuousTargets */;
30887
+ return 82 /* CommandResult.NonContinuousTargets */;
30824
30888
  }
30825
30889
  const zone = union(...cmd.target);
30826
30890
  const checkFilterOverlap = () => {
30827
30891
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
30828
- return 78 /* CommandResult.FilterOverlap */;
30892
+ return 79 /* CommandResult.FilterOverlap */;
30829
30893
  }
30830
30894
  return 0 /* CommandResult.Success */;
30831
30895
  };
@@ -30833,7 +30897,7 @@ class FiltersPlugin extends CorePlugin {
30833
30897
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
30834
30898
  for (let merge of mergesInTarget) {
30835
30899
  if (overlap(zone, merge)) {
30836
- return 80 /* CommandResult.MergeInFilter */;
30900
+ return 81 /* CommandResult.MergeInFilter */;
30837
30901
  }
30838
30902
  }
30839
30903
  return 0 /* CommandResult.Success */;
@@ -30843,7 +30907,7 @@ class FiltersPlugin extends CorePlugin {
30843
30907
  for (let merge of cmd.target) {
30844
30908
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
30845
30909
  if (overlap(filterTable.zone, merge)) {
30846
- return 80 /* CommandResult.MergeInFilter */;
30910
+ return 81 /* CommandResult.MergeInFilter */;
30847
30911
  }
30848
30912
  }
30849
30913
  }
@@ -31328,10 +31392,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
31328
31392
  : this.getters.getNumberRows(cmd.sheetId);
31329
31393
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
31330
31394
  if (hiddenElements.size >= elements) {
31331
- return 66 /* CommandResult.TooManyHiddenElements */;
31395
+ return 67 /* CommandResult.TooManyHiddenElements */;
31332
31396
  }
31333
31397
  else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31334
- return 86 /* CommandResult.InvalidHeaderIndex */;
31398
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31335
31399
  }
31336
31400
  else {
31337
31401
  return 0 /* CommandResult.Success */;
@@ -31874,7 +31938,7 @@ class MergePlugin extends CorePlugin {
31874
31938
  for (const zone of target) {
31875
31939
  for (const zone2 of target) {
31876
31940
  if (zone !== zone2 && overlap(zone, zone2)) {
31877
- return 65 /* CommandResult.MergeOverlap */;
31941
+ return 66 /* CommandResult.MergeOverlap */;
31878
31942
  }
31879
31943
  }
31880
31944
  }
@@ -31888,7 +31952,7 @@ class MergePlugin extends CorePlugin {
31888
31952
  for (const zone of target) {
31889
31953
  if ((zone.left < xSplit && zone.right >= xSplit) ||
31890
31954
  (zone.top < ySplit && zone.bottom >= ySplit)) {
31891
- return 75 /* CommandResult.FrozenPaneOverlap */;
31955
+ return 76 /* CommandResult.FrozenPaneOverlap */;
31892
31956
  }
31893
31957
  }
31894
31958
  return 0 /* CommandResult.Success */;
@@ -32346,8 +32410,9 @@ class RangeAdapter {
32346
32410
  *
32347
32411
  * @param range the range (received from getRangeFromXC or getRangeFromZone)
32348
32412
  * @param forSheetId the id of the sheet where the range string is supposed to be used.
32413
+ * @param [useFixedZone=false] if true, the range will be returned with fixed row and column
32349
32414
  */
32350
- getRangeString(range, forSheetId) {
32415
+ getRangeString(range, forSheetId, useFixedZone = false) {
32351
32416
  if (!range) {
32352
32417
  return INCORRECT_RANGE_STRING;
32353
32418
  }
@@ -32374,7 +32439,7 @@ class RangeAdapter {
32374
32439
  if (prefixSheet && !sheetName) {
32375
32440
  return INCORRECT_RANGE_STRING;
32376
32441
  }
32377
- let rangeString = this.getRangePartString(rangeImpl, 0);
32442
+ let rangeString = this.getRangePartString(rangeImpl, 0, useFixedZone);
32378
32443
  if (rangeImpl.parts && rangeImpl.parts.length === 2) {
32379
32444
  // this if converts A2:A2 into A2 except if any part of the original range had fixed row or column (with $)
32380
32445
  if (rangeImpl.zone.top !== rangeImpl.zone.bottom ||
@@ -32384,7 +32449,7 @@ class RangeAdapter {
32384
32449
  rangeImpl.parts[1].rowFixed ||
32385
32450
  rangeImpl.parts[1].colFixed) {
32386
32451
  rangeString += ":";
32387
- rangeString += this.getRangePartString(rangeImpl, 1);
32452
+ rangeString += this.getRangePartString(rangeImpl, 1, useFixedZone);
32388
32453
  }
32389
32454
  }
32390
32455
  return `${prefixSheet ? sheetName + "!" : ""}${rangeString}`;
@@ -32414,13 +32479,13 @@ class RangeAdapter {
32414
32479
  /**
32415
32480
  * Get a Xc string that represent a part of a range
32416
32481
  */
32417
- getRangePartString(range, part) {
32418
- const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
32482
+ getRangePartString(range, part, useFixedZone = false) {
32483
+ const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
32419
32484
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
32420
- const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
32485
+ const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
32421
32486
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
32422
32487
  let str = "";
32423
- if (range.isFullCol) {
32488
+ if (range.isFullCol && !useFixedZone) {
32424
32489
  if (part === 0 && range.unboundedZone.hasHeader) {
32425
32490
  str = colFixed + col + rowFixed + row;
32426
32491
  }
@@ -32428,7 +32493,7 @@ class RangeAdapter {
32428
32493
  str = colFixed + col;
32429
32494
  }
32430
32495
  }
32431
- else if (range.isFullRow) {
32496
+ else if (range.isFullRow && !useFixedZone) {
32432
32497
  if (part === 0 && range.unboundedZone.hasHeader) {
32433
32498
  str = colFixed + col + rowFixed + row;
32434
32499
  }
@@ -32524,10 +32589,10 @@ class SheetPlugin extends CorePlugin {
32524
32589
  ? this.getNumberCols(cmd.sheetId)
32525
32590
  : this.getNumberRows(cmd.sheetId);
32526
32591
  if (cmd.base < 0 || cmd.base >= elements) {
32527
- return 86 /* CommandResult.InvalidHeaderIndex */;
32592
+ return 87 /* CommandResult.InvalidHeaderIndex */;
32528
32593
  }
32529
32594
  else if (cmd.quantity <= 0) {
32530
- return 87 /* CommandResult.InvalidQuantity */;
32595
+ return 88 /* CommandResult.InvalidQuantity */;
32531
32596
  }
32532
32597
  return 0 /* CommandResult.Success */;
32533
32598
  case "REMOVE_COLUMNS_ROWS": {
@@ -32535,7 +32600,7 @@ class SheetPlugin extends CorePlugin {
32535
32600
  ? this.getNumberCols(cmd.sheetId)
32536
32601
  : this.getNumberRows(cmd.sheetId);
32537
32602
  if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
32538
- return 86 /* CommandResult.InvalidHeaderIndex */;
32603
+ return 87 /* CommandResult.InvalidHeaderIndex */;
32539
32604
  }
32540
32605
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
32541
32606
  return 8 /* CommandResult.NotEnoughElements */;
@@ -33001,18 +33066,18 @@ class SheetPlugin extends CorePlugin {
33001
33066
  checkRowFreezeQuantity(cmd) {
33002
33067
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
33003
33068
  ? 0 /* CommandResult.Success */
33004
- : 74 /* CommandResult.InvalidFreezeQuantity */;
33069
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
33005
33070
  }
33006
33071
  checkColFreezeQuantity(cmd) {
33007
33072
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
33008
33073
  ? 0 /* CommandResult.Success */
33009
- : 74 /* CommandResult.InvalidFreezeQuantity */;
33074
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
33010
33075
  }
33011
33076
  checkRowFreezeOverlapMerge(cmd) {
33012
33077
  const merges = this.getters.getMerges(cmd.sheetId);
33013
33078
  for (let merge of merges) {
33014
33079
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
33015
- return 65 /* CommandResult.MergeOverlap */;
33080
+ return 66 /* CommandResult.MergeOverlap */;
33016
33081
  }
33017
33082
  }
33018
33083
  return 0 /* CommandResult.Success */;
@@ -33021,7 +33086,7 @@ class SheetPlugin extends CorePlugin {
33021
33086
  const merges = this.getters.getMerges(cmd.sheetId);
33022
33087
  for (let merge of merges) {
33023
33088
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
33024
- return 65 /* CommandResult.MergeOverlap */;
33089
+ return 66 /* CommandResult.MergeOverlap */;
33025
33090
  }
33026
33091
  }
33027
33092
  return 0 /* CommandResult.Success */;
@@ -33752,10 +33817,8 @@ class EvaluationPlugin extends UIPlugin {
33752
33817
  * that are actually present in the grid.
33753
33818
  */
33754
33819
  function range(range) {
33820
+ assertRangeValid(range);
33755
33821
  const sheetId = range.sheetId;
33756
- if (!isZoneValid(range.zone)) {
33757
- throw new InvalidReferenceError();
33758
- }
33759
33822
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
33760
33823
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
33761
33824
  const sheetZone = getters.getSheetZone(sheetId);
@@ -33790,23 +33853,26 @@ class EvaluationPlugin extends UIPlugin {
33790
33853
  * The `compute` of the formula's function must process it completely
33791
33854
  */
33792
33855
  function refFn(range, isMeta, functionName, paramNumber) {
33856
+ assertRangeValid(range);
33793
33857
  if (isMeta) {
33794
33858
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
33795
33859
  return { value: zoneToXc(range.zone) };
33796
33860
  }
33797
- if (!isZoneValid(range.zone)) {
33798
- throw new InvalidReferenceError();
33799
- }
33800
33861
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
33801
33862
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
33802
33863
  throw new Error(paramNumber
33803
33864
  ? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
33804
33865
  : _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
33805
33866
  }
33867
+ return readCell(range);
33868
+ }
33869
+ function assertRangeValid(range) {
33870
+ if (!isZoneValid(range.zone)) {
33871
+ throw new InvalidReferenceError();
33872
+ }
33806
33873
  if (range.invalidSheetName) {
33807
33874
  throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
33808
33875
  }
33809
- return readCell(range);
33810
33876
  }
33811
33877
  return [refFn, range, evalContext];
33812
33878
  }
@@ -33826,6 +33892,10 @@ class EvaluationPlugin extends UIPlugin {
33826
33892
  if (cell.format !== evaluatedCell.format) {
33827
33893
  exportedCellData.computedFormat = evaluatedCell.format;
33828
33894
  }
33895
+ // if there is a formula but no dependencies (maybe because the cell is in error), no need to recompute the formula text
33896
+ if (cell.isFormula && cell.dependencies.length) {
33897
+ exportedCellData.content = this.getters.buildFormulaContent(sheet.id, cell, cell.dependencies, true);
33898
+ }
33829
33899
  }
33830
33900
  }
33831
33901
  }
@@ -34291,7 +34361,7 @@ class FilterEvaluationPlugin extends UIPlugin {
34291
34361
  switch (cmd.type) {
34292
34362
  case "UPDATE_FILTER":
34293
34363
  if (!this.getters.getFilterId(cmd)) {
34294
- return 79 /* CommandResult.FilterNotFound */;
34364
+ return 80 /* CommandResult.FilterNotFound */;
34295
34365
  }
34296
34366
  break;
34297
34367
  }
@@ -35261,7 +35331,7 @@ class SheetViewPlugin extends UIPlugin {
35261
35331
  }
35262
35332
  checkPositiveDimension(cmd) {
35263
35333
  if (cmd.width < 0 || cmd.height < 0) {
35264
- return 68 /* CommandResult.InvalidViewportSize */;
35334
+ return 69 /* CommandResult.InvalidViewportSize */;
35265
35335
  }
35266
35336
  return 0 /* CommandResult.Success */;
35267
35337
  }
@@ -35271,7 +35341,7 @@ class SheetViewPlugin extends UIPlugin {
35271
35341
  cmd.gridOffsetY === this.gridOffsetY &&
35272
35342
  cmd.width === width &&
35273
35343
  cmd.height === height) {
35274
- return 76 /* CommandResult.ValuesNotChanged */;
35344
+ return 77 /* CommandResult.ValuesNotChanged */;
35275
35345
  }
35276
35346
  return 0 /* CommandResult.Success */;
35277
35347
  }
@@ -35279,7 +35349,7 @@ class SheetViewPlugin extends UIPlugin {
35279
35349
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
35280
35350
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
35281
35351
  (!pane.canScrollVertically && offsetY > 0)) {
35282
- return 69 /* CommandResult.InvalidScrollingDirection */;
35352
+ return 70 /* CommandResult.InvalidScrollingDirection */;
35283
35353
  }
35284
35354
  return 0 /* CommandResult.Success */;
35285
35355
  }
@@ -35534,7 +35604,7 @@ class AutofillPlugin extends UIPlugin {
35534
35604
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
35535
35605
  return 0 /* CommandResult.Success */;
35536
35606
  }
35537
- return 45 /* CommandResult.InvalidAutofillSelection */;
35607
+ return 46 /* CommandResult.InvalidAutofillSelection */;
35538
35608
  case "AUTOFILL_AUTO":
35539
35609
  const zone = this.getters.getSelectedZone();
35540
35610
  return zone.top === zone.bottom
@@ -36138,7 +36208,7 @@ class CellPopoverPlugin extends UIPlugin {
36138
36208
  cellPopoverRegistry.get(cmd.popoverType);
36139
36209
  }
36140
36210
  catch (error) {
36141
- return 72 /* CommandResult.InvalidCellPopover */;
36211
+ return 73 /* CommandResult.InvalidCellPopover */;
36142
36212
  }
36143
36213
  return 0 /* CommandResult.Success */;
36144
36214
  default:
@@ -38274,21 +38344,6 @@ class SelectionInputPlugin extends UIPlugin {
38274
38344
  // ---------------------------------------------------------------------------
38275
38345
  // Command Handling
38276
38346
  // ---------------------------------------------------------------------------
38277
- allowDispatch(cmd) {
38278
- switch (cmd.type) {
38279
- case "ADD_EMPTY_RANGE":
38280
- if (this.inputHasSingleRange && this.ranges.length === 1) {
38281
- return 30 /* CommandResult.MaximumRangesReached */;
38282
- }
38283
- break;
38284
- case "CHANGE_RANGE":
38285
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
38286
- return 30 /* CommandResult.MaximumRangesReached */;
38287
- }
38288
- break;
38289
- }
38290
- return 0 /* CommandResult.Success */;
38291
- }
38292
38347
  handleEvent(event) {
38293
38348
  const xc = zoneToXc(event.anchor.zone);
38294
38349
  const inputSheetId = this.activeSheet;
@@ -38504,6 +38559,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
38504
38559
  // Command Handling
38505
38560
  // ---------------------------------------------------------------------------
38506
38561
  allowDispatch(cmd) {
38562
+ switch (cmd.type) {
38563
+ case "FOCUS_RANGE":
38564
+ case "CHANGE_RANGE":
38565
+ case "ADD_EMPTY_RANGE":
38566
+ case "REMOVE_RANGE":
38567
+ if (!this.inputs[cmd.id]) {
38568
+ return 31 /* CommandResult.InvalidInputId */;
38569
+ }
38570
+ }
38507
38571
  switch (cmd.type) {
38508
38572
  case "FOCUS_RANGE":
38509
38573
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -38511,9 +38575,19 @@ class SelectionInputsManagerPlugin extends UIPlugin {
38511
38575
  return 29 /* CommandResult.InputAlreadyFocused */;
38512
38576
  }
38513
38577
  break;
38514
- }
38515
- if (this.currentInput) {
38516
- return this.currentInput.allowDispatch(cmd);
38578
+ case "ADD_EMPTY_RANGE":
38579
+ const input = this.inputs[cmd.id];
38580
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
38581
+ return 30 /* CommandResult.MaximumRangesReached */;
38582
+ }
38583
+ break;
38584
+ case "CHANGE_RANGE": {
38585
+ const input = this.inputs[cmd.id];
38586
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
38587
+ return 30 /* CommandResult.MaximumRangesReached */;
38588
+ }
38589
+ break;
38590
+ }
38517
38591
  }
38518
38592
  return 0 /* CommandResult.Success */;
38519
38593
  }
@@ -38637,7 +38711,7 @@ class SortPlugin extends UIPlugin {
38637
38711
  /*Test the presence of single cells*/
38638
38712
  const singleCells = positions(zone).some(({ col, row }) => !this.getters.isInMerge({ sheetId, col, row }));
38639
38713
  if (singleCells) {
38640
- return 63 /* CommandResult.InvalidSortZone */;
38714
+ return 64 /* CommandResult.InvalidSortZone */;
38641
38715
  }
38642
38716
  return 0 /* CommandResult.Success */;
38643
38717
  }
@@ -38656,7 +38730,7 @@ class SortPlugin extends UIPlugin {
38656
38730
  ];
38657
38731
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
38658
38732
  })) {
38659
- return 63 /* CommandResult.InvalidSortZone */;
38733
+ return 64 /* CommandResult.InvalidSortZone */;
38660
38734
  }
38661
38735
  return 0 /* CommandResult.Success */;
38662
38736
  }
@@ -39159,7 +39233,7 @@ class SheetUIPlugin extends UIPlugin {
39159
39233
  const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.tryGetActiveSheetId();
39160
39234
  const zones = this.getters.getCommandZones(cmd);
39161
39235
  if (!sheetId && zones.length > 0) {
39162
- return 92 /* CommandResult.NoActiveSheet */;
39236
+ return 93 /* CommandResult.NoActiveSheet */;
39163
39237
  }
39164
39238
  if (sheetId && zones.length > 0) {
39165
39239
  return this.getters.checkZonesExistInSheet(sheetId, zones);
@@ -39641,13 +39715,13 @@ class SplitToColumnsPlugin extends UIPlugin {
39641
39715
  }
39642
39716
  checkSingleColSelected() {
39643
39717
  if (!this.getters.isSingleColSelected()) {
39644
- return 88 /* CommandResult.MoreThanOneColumnSelected */;
39718
+ return 89 /* CommandResult.MoreThanOneColumnSelected */;
39645
39719
  }
39646
39720
  return 0 /* CommandResult.Success */;
39647
39721
  }
39648
39722
  checkNonEmptySelector(cmd) {
39649
39723
  if (cmd.separator === "") {
39650
- return 89 /* CommandResult.EmptySplitSeparator */;
39724
+ return 90 /* CommandResult.EmptySplitSeparator */;
39651
39725
  }
39652
39726
  return 0 /* CommandResult.Success */;
39653
39727
  }
@@ -39658,7 +39732,7 @@ class SplitToColumnsPlugin extends UIPlugin {
39658
39732
  const selection = this.getters.getSelectedZones()[0];
39659
39733
  const splitted = this.getSplittedCols(selection, cmd.separator);
39660
39734
  if (this.willSplittedColsOverwriteContent(selection, splitted)) {
39661
- return 90 /* CommandResult.SplitWillOverwriteContent */;
39735
+ return 91 /* CommandResult.SplitWillOverwriteContent */;
39662
39736
  }
39663
39737
  return 0 /* CommandResult.Success */;
39664
39738
  }
@@ -39669,7 +39743,7 @@ class SplitToColumnsPlugin extends UIPlugin {
39669
39743
  return 0 /* CommandResult.Success */;
39670
39744
  }
39671
39745
  }
39672
- return 91 /* CommandResult.NoSplitSeparatorInSelection */;
39746
+ return 92 /* CommandResult.NoSplitSeparatorInSelection */;
39673
39747
  }
39674
39748
  }
39675
39749
 
@@ -39816,7 +39890,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
39816
39890
  for (const zone of this.getPasteZones(target)) {
39817
39891
  if ((zone.left < xSplit && zone.right >= xSplit) ||
39818
39892
  (zone.top < ySplit && zone.bottom >= ySplit)) {
39819
- return 75 /* CommandResult.FrozenPaneOverlap */;
39893
+ return 76 /* CommandResult.FrozenPaneOverlap */;
39820
39894
  }
39821
39895
  }
39822
39896
  return 0 /* CommandResult.Success */;
@@ -40210,7 +40284,7 @@ class ClipboardFigureState {
40210
40284
  }
40211
40285
  isPasteAllowed(target, option) {
40212
40286
  if (target.length === 0) {
40213
- return 73 /* CommandResult.EmptyTarget */;
40287
+ return 74 /* CommandResult.EmptyTarget */;
40214
40288
  }
40215
40289
  if (option?.pasteOption !== undefined) {
40216
40290
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -40951,7 +41025,7 @@ class EditionPlugin extends UIPlugin {
40951
41025
  validateSelection(length, start, end) {
40952
41026
  return start >= 0 && start <= length && end >= 0 && end <= length
40953
41027
  ? 0 /* CommandResult.Success */
40954
- : 46 /* CommandResult.WrongComposerSelection */;
41028
+ : 47 /* CommandResult.WrongComposerSelection */;
40955
41029
  }
40956
41030
  onColumnsRemoved(cmd) {
40957
41031
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -41166,7 +41240,7 @@ class EditionPlugin extends UIPlugin {
41166
41240
  getZoneReference(zone, fixedParts = [{ colFixed: false, rowFixed: false }]) {
41167
41241
  const sheetId = this.getters.getActiveSheetId();
41168
41242
  let selectedXc = this.getters.zoneToXC(sheetId, zone, fixedParts);
41169
- if (this.getters.getCurrentEditedCell().sheetId !== this.getters.getActiveSheetId()) {
41243
+ if (this.getters.getCurrentEditedCell()?.sheetId !== this.getters.getActiveSheetId()) {
41170
41244
  const sheetName = getCanonicalSheetName(this.getters.getSheetName(this.getters.getActiveSheetId()));
41171
41245
  selectedXc = `${sheetName}!${selectedXc}`;
41172
41246
  }
@@ -41181,7 +41255,7 @@ class EditionPlugin extends UIPlugin {
41181
41255
  _fixedParts.pop();
41182
41256
  }
41183
41257
  const newRange = range.clone({ parts: _fixedParts });
41184
- return this.getters.getSelectionRangeString(newRange, this.getters.getCurrentEditedCell().sheetId);
41258
+ return this.getters.getSelectionRangeString(newRange, this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId());
41185
41259
  }
41186
41260
  /**
41187
41261
  * Replace the current selection by a new text.
@@ -41214,7 +41288,7 @@ class EditionPlugin extends UIPlugin {
41214
41288
  if (!this.currentContent.startsWith("=") || this.mode === "inactive") {
41215
41289
  return;
41216
41290
  }
41217
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41291
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41218
41292
  const XCs = this.getReferencedRanges().map((range) => this.getters.getRangeString(range, editionSheetId));
41219
41293
  const colorsToKeep = {};
41220
41294
  for (const xc of XCs) {
@@ -41243,7 +41317,7 @@ class EditionPlugin extends UIPlugin {
41243
41317
  if (!this.currentContent.startsWith("=") || this.mode === "inactive") {
41244
41318
  return [];
41245
41319
  }
41246
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41320
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41247
41321
  const rangeColor = (rangeString) => {
41248
41322
  const colorIndex = this.colorIndexByRange[rangeString];
41249
41323
  return colors$1[colorIndex % colors$1.length];
@@ -41261,10 +41335,11 @@ class EditionPlugin extends UIPlugin {
41261
41335
  * Return ranges currently referenced in the composer
41262
41336
  */
41263
41337
  getReferencedRanges() {
41264
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41265
- return this.currentTokens
41338
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41339
+ const referenceRanges = this.currentTokens
41266
41340
  .filter((token) => token.type === "REFERENCE")
41267
41341
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
41342
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
41268
41343
  }
41269
41344
  /**
41270
41345
  * Function used to determine when composer selection can start.
@@ -41903,7 +41978,7 @@ class GridSelectionPlugin extends UIPlugin {
41903
41978
  const headers = [cmd.base, ...cmd.elements];
41904
41979
  const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
41905
41980
  if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
41906
- return 86 /* CommandResult.InvalidHeaderIndex */;
41981
+ return 87 /* CommandResult.InvalidHeaderIndex */;
41907
41982
  }
41908
41983
  return 0 /* CommandResult.Success */;
41909
41984
  }
@@ -42071,6 +42146,16 @@ class ImageProvider {
42071
42146
  }
42072
42147
  }
42073
42148
 
42149
+ class FocusableElement {
42150
+ focusableElement = undefined;
42151
+ setFocusableElement(element) {
42152
+ this.focusableElement = element;
42153
+ }
42154
+ focus() {
42155
+ this.focusableElement?.focus();
42156
+ }
42157
+ }
42158
+
42074
42159
  const RIPPLE_KEY_FRAMES = [
42075
42160
  { transform: "scale(0)" },
42076
42161
  { transform: "scale(0.8)", offset: 0.33 },
@@ -44099,6 +44184,7 @@ class Spreadsheet extends Component {
44099
44184
  _t: Spreadsheet._t,
44100
44185
  clipboard: this.env.clipboard || instantiateClipboard(),
44101
44186
  startCellEdition: (content) => this.onGridComposerCellFocused(content),
44187
+ focusableElement: new FocusableElement(),
44102
44188
  });
44103
44189
  useExternalListener(window, "resize", () => this.render(true));
44104
44190
  useExternalListener(window, "beforeunload", this.unbindModelEvents.bind(this));
@@ -44205,17 +44291,18 @@ class Spreadsheet extends Component {
44205
44291
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
44206
44292
  this.composer.topBarFocus = "contentFocus";
44207
44293
  this.composer.gridFocusMode = "inactive";
44208
- this.setComposerContent({ selection } || {});
44294
+ this.setComposerContent({ selection });
44209
44295
  }
44210
- onGridComposerContentFocused() {
44296
+ onGridComposerContentFocused(selection) {
44211
44297
  if (this.model.getters.isReadonly()) {
44212
44298
  return;
44213
44299
  }
44214
44300
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
44215
44301
  this.composer.topBarFocus = "inactive";
44216
44302
  this.composer.gridFocusMode = "contentFocus";
44217
- this.setComposerContent({});
44303
+ this.setComposerContent({ selection });
44218
44304
  }
44305
+ // TODO: either both are defined or none of them. change those args to an object
44219
44306
  onGridComposerCellFocused(content, selection) {
44220
44307
  if (this.model.getters.isReadonly()) {
44221
44308
  return;
@@ -45252,7 +45339,7 @@ class SelectionStreamProcessorImpl {
45252
45339
  */
45253
45340
  moveAnchorCell(direction, step = 1) {
45254
45341
  if (step !== "end" && step <= 0) {
45255
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
45342
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
45256
45343
  }
45257
45344
  const { col, row } = this.getNextAvailablePosition(direction, step);
45258
45345
  return this.selectCell(col, row);
@@ -45298,7 +45385,7 @@ class SelectionStreamProcessorImpl {
45298
45385
  */
45299
45386
  resizeAnchorZone(direction, step = 1) {
45300
45387
  if (step !== "end" && step <= 0) {
45301
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
45388
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
45302
45389
  }
45303
45390
  const sheetId = this.getters.getActiveSheetId();
45304
45391
  const anchor = this.anchor;
@@ -46125,12 +46212,7 @@ function addFormula(cell) {
46125
46212
  attrs.push(["t", "str"]);
46126
46213
  cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
46127
46214
  }
46128
- node = escapeXml /*xml*/ `
46129
- <f>
46130
- ${XlsxFormula}
46131
- </f>
46132
- ${cycle}
46133
- `;
46215
+ node = escapeXml /*xml*/ `<f> ${XlsxFormula} </f> ${cycle}`;
46134
46216
  return { attrs, node };
46135
46217
  }
46136
46218
  else {
@@ -46952,11 +47034,10 @@ function addRows(construct, data, sheet) {
46952
47034
  ({ attrs: additionalAttrs, node: cellNode } = addContent(cell.content, construct.sharedStrings, isTableHeader));
46953
47035
  }
46954
47036
  attributes.push(...additionalAttrs);
46955
- cellNodes.push(escapeXml /*xml*/ `
46956
- <c ${formatAttributes(attributes)}>
46957
- ${cellNode}
46958
- </c>
46959
- `);
47037
+ // prettier-ignore
47038
+ cellNodes.push(escapeXml /*xml*/ `<c ${formatAttributes(attributes)}>
47039
+ ${cellNode}
47040
+ </c>`);
46960
47041
  }
46961
47042
  }
46962
47043
  if (cellNodes.length || row.size !== DEFAULT_CELL_HEIGHT || row.isHidden) {
@@ -47641,10 +47722,10 @@ class Model extends EventBus {
47641
47722
  const command = createCommand(type, payload);
47642
47723
  let status = this.status;
47643
47724
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
47644
- return new DispatchResult(67 /* CommandResult.Readonly */);
47725
+ return new DispatchResult(68 /* CommandResult.Readonly */);
47645
47726
  }
47646
47727
  if (!this.session.canApplyOptimisticUpdate()) {
47647
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
47728
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
47648
47729
  }
47649
47730
  switch (status) {
47650
47731
  case 0 /* Status.Ready */:
@@ -47895,6 +47976,6 @@ function addFunction(functionName, functionDescription) {
47895
47976
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
47896
47977
 
47897
47978
 
47898
- __info__.version = '16.3.22';
47899
- __info__.date = '2024-01-17T10:24:07.652Z';
47900
- __info__.hash = '2c1b136';
47979
+ __info__.version = '16.3.25';
47980
+ __info__.date = '2024-02-09T13:07:06.947Z';
47981
+ __info__.hash = 'b53bf1b';