@odoo/o-spreadsheet 17.0.2 → 17.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.0.2
6
- * @date 2023-11-03T12:22:44.945Z
7
- * @hash 3184728
5
+ * @version 17.0.3
6
+ * @date 2023-11-16T11:59:49.524Z
7
+ * @hash 8bd0fb2
8
8
  */
9
9
 
10
10
  'use strict';
@@ -4542,14 +4542,14 @@ function drawDecoratedText(context, text, position, underline = false, strikethr
4542
4542
  switch (context.textBaseline) {
4543
4543
  case "top":
4544
4544
  underlineY += boxHeight - 2 * strokeWidth;
4545
- strikeY += boxHeight - textHeight;
4545
+ strikeY += boxHeight / 2 - strokeWidth;
4546
4546
  break;
4547
4547
  case "middle":
4548
4548
  underlineY += boxHeight / 2 - strokeWidth;
4549
4549
  break;
4550
4550
  case "alphabetic":
4551
4551
  underlineY += 2 * strokeWidth;
4552
- strikeY -= textHeight / 2 - strokeWidth / 2;
4552
+ strikeY -= 3 * strokeWidth;
4553
4553
  break;
4554
4554
  case "bottom":
4555
4555
  underlineY = y;
@@ -5968,7 +5968,7 @@ autofillModifiersRegistry
5968
5968
  return { cellData: {} };
5969
5969
  }
5970
5970
  const sheetId = data.sheetId;
5971
- const content = getters.getTranslatedCellFormula(sheetId, x, y, cell.compiledFormula, cell.dependencies);
5971
+ const content = getters.getTranslatedCellFormula(sheetId, x, y, cell.compiledFormula);
5972
5972
  return {
5973
5973
  cellData: {
5974
5974
  border: data.border,
@@ -10695,6 +10695,17 @@ const SELECTION_CONTAINS_FILTER = (env) => {
10695
10695
  const IS_ONLY_ONE_RANGE = (env) => {
10696
10696
  return env.model.getters.getSelectedZones().length === 1;
10697
10697
  };
10698
+ const CAN_INSERT_HEADER = (env, dimension) => {
10699
+ if (!IS_ONLY_ONE_RANGE(env)) {
10700
+ return false;
10701
+ }
10702
+ const activeHeaders = dimension === "COL" ? env.model.getters.getActiveCols() : env.model.getters.getActiveRows();
10703
+ const ortogonalActiveHeaders = dimension === "COL" ? env.model.getters.getActiveRows() : env.model.getters.getActiveCols();
10704
+ const sheetId = env.model.getters.getActiveSheetId();
10705
+ const zone = env.model.getters.getSelectedZone();
10706
+ const allSheetSelected = isEqual(zone, env.model.getters.getSheetZone(sheetId));
10707
+ return isConsecutive(activeHeaders) && (ortogonalActiveHeaders.size === 0 || allSheetSelected);
10708
+ };
10698
10709
 
10699
10710
  const undo = {
10700
10711
  name: _t("Undo"),
@@ -19372,9 +19383,7 @@ const insertRow = {
19372
19383
  const number = getRowsNumber(env);
19373
19384
  return number === 1 ? _t("Insert row") : _t("Insert %s rows", number.toString());
19374
19385
  },
19375
- isVisible: (env) => isConsecutive(env.model.getters.getActiveRows()) &&
19376
- IS_ONLY_ONE_RANGE(env) &&
19377
- env.model.getters.getActiveCols().size === 0,
19386
+ isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
19378
19387
  icon: "o-spreadsheet-Icon.INSERT_ROW",
19379
19388
  };
19380
19389
  const rowInsertRowBefore = {
@@ -19383,9 +19392,7 @@ const rowInsertRowBefore = {
19383
19392
  return number === 1 ? _t("Insert row above") : _t("Insert %s rows above", number.toString());
19384
19393
  },
19385
19394
  execute: INSERT_ROWS_BEFORE_ACTION,
19386
- isVisible: (env) => isConsecutive(env.model.getters.getActiveRows()) &&
19387
- IS_ONLY_ONE_RANGE(env) &&
19388
- env.model.getters.getActiveCols().size === 0,
19395
+ isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
19389
19396
  icon: "o-spreadsheet-Icon.INSERT_ROW_BEFORE",
19390
19397
  };
19391
19398
  const topBarInsertRowsBefore = {
@@ -19416,9 +19423,7 @@ const rowInsertRowsAfter = {
19416
19423
  const number = getRowsNumber(env);
19417
19424
  return number === 1 ? _t("Insert row below") : _t("Insert %s rows below", number.toString());
19418
19425
  },
19419
- isVisible: (env) => isConsecutive(env.model.getters.getActiveRows()) &&
19420
- IS_ONLY_ONE_RANGE(env) &&
19421
- env.model.getters.getActiveCols().size === 0,
19426
+ isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
19422
19427
  icon: "o-spreadsheet-Icon.INSERT_ROW_AFTER",
19423
19428
  };
19424
19429
  const topBarInsertRowsAfter = {
@@ -19436,9 +19441,7 @@ const insertCol = {
19436
19441
  const number = getColumnsNumber(env);
19437
19442
  return number === 1 ? _t("Insert column") : _t("Insert %s columns", number.toString());
19438
19443
  },
19439
- isVisible: (env) => isConsecutive(env.model.getters.getActiveCols()) &&
19440
- IS_ONLY_ONE_RANGE(env) &&
19441
- env.model.getters.getActiveRows().size === 0,
19444
+ isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
19442
19445
  icon: "o-spreadsheet-Icon.INSERT_COL",
19443
19446
  };
19444
19447
  const colInsertColsBefore = {
@@ -19449,9 +19452,7 @@ const colInsertColsBefore = {
19449
19452
  : _t("Insert %s columns left", number.toString());
19450
19453
  },
19451
19454
  execute: INSERT_COLUMNS_BEFORE_ACTION,
19452
- isVisible: (env) => isConsecutive(env.model.getters.getActiveCols()) &&
19453
- IS_ONLY_ONE_RANGE(env) &&
19454
- env.model.getters.getActiveRows().size === 0,
19455
+ isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
19455
19456
  icon: "o-spreadsheet-Icon.INSERT_COL_BEFORE",
19456
19457
  };
19457
19458
  const topBarInsertColsBefore = {
@@ -19484,9 +19485,7 @@ const colInsertColsAfter = {
19484
19485
  : _t("Insert %s columns right", number.toString());
19485
19486
  },
19486
19487
  execute: INSERT_COLUMNS_AFTER_ACTION,
19487
- isVisible: (env) => isConsecutive(env.model.getters.getActiveCols()) &&
19488
- IS_ONLY_ONE_RANGE(env) &&
19489
- env.model.getters.getActiveRows().size === 0,
19488
+ isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
19490
19489
  icon: "o-spreadsheet-Icon.INSERT_COL_AFTER",
19491
19490
  };
19492
19491
  const topBarInsertColsAfter = {
@@ -23827,7 +23826,7 @@ css /* scss */ `
23827
23826
  }
23828
23827
  .o-input-count {
23829
23828
  width: fit-content;
23830
- padding: 4 0 4 4;
23829
+ padding: 4px 0 4px 4px;
23831
23830
  }
23832
23831
  }
23833
23832
  }
@@ -34948,6 +34947,9 @@ const functionCache = {};
34948
34947
  // -----------------------------------------------------------------------------
34949
34948
  function compile(formula) {
34950
34949
  const tokens = rangeTokenize(formula);
34950
+ return compileTokens(tokens);
34951
+ }
34952
+ function compileTokens(tokens) {
34951
34953
  const { dependencies, constantValues } = formulaArguments(tokens);
34952
34954
  const cacheKey = compilationCacheKey(tokens, dependencies, constantValues);
34953
34955
  if (!functionCache[cacheKey]) {
@@ -35314,11 +35316,11 @@ class CellPlugin extends CorePlugin {
35314
35316
  for (const sheet of Object.keys(this.cells)) {
35315
35317
  for (const cell of Object.values(this.cells[sheet] || {})) {
35316
35318
  if (cell.isFormula) {
35317
- for (const range of cell.dependencies) {
35319
+ for (const range of cell.compiledFormula.dependencies) {
35318
35320
  if (!sheetId || range.sheetId === sheetId) {
35319
35321
  const change = applyChange(range);
35320
35322
  if (change.changeType !== "NONE") {
35321
- this.history.update("cells", sheet, cell.id, "dependencies", cell.dependencies.indexOf(range), change.range);
35323
+ this.history.update("cells", sheet, cell.id, "compiledFormula", "dependencies", cell.compiledFormula.dependencies.indexOf(range), change.range);
35322
35324
  }
35323
35325
  }
35324
35326
  }
@@ -35514,10 +35516,10 @@ class CellPlugin extends CorePlugin {
35514
35516
  /*
35515
35517
  * Reconstructs the original formula string based on a normalized form and its dependencies
35516
35518
  */
35517
- getFormulaCellContent(sheetId, cell, dependencies) {
35518
- const ranges = dependencies || cell.dependencies;
35519
+ getFormulaCellContent(sheetId, compiledFormula, dependencies) {
35520
+ const ranges = dependencies || compiledFormula.dependencies;
35519
35521
  let rangeIndex = 0;
35520
- return concat(cell.compiledFormula.tokens.map((token) => {
35522
+ return concat(compiledFormula.tokens.map((token) => {
35521
35523
  if (token.type === "REFERENCE") {
35522
35524
  const range = ranges[rangeIndex++];
35523
35525
  return this.getters.getRangeString(range, sheetId);
@@ -35528,12 +35530,9 @@ class CellPlugin extends CorePlugin {
35528
35530
  /*
35529
35531
  * Constructs a formula string based on an initial formula and a translation vector
35530
35532
  */
35531
- getTranslatedCellFormula(sheetId, offsetX, offsetY, compiledFormula, dependencies) {
35532
- const adaptedDependencies = this.getters.createAdaptedRanges(dependencies, offsetX, offsetY, sheetId);
35533
- return this.getFormulaCellContent(sheetId, {
35534
- compiledFormula,
35535
- dependencies: adaptedDependencies,
35536
- });
35533
+ getTranslatedCellFormula(sheetId, offsetX, offsetY, compiledFormula) {
35534
+ const adaptedDependencies = this.getters.createAdaptedRanges(compiledFormula.dependencies, offsetX, offsetY, sheetId);
35535
+ return this.getFormulaCellContent(sheetId, compiledFormula, adaptedDependencies);
35537
35536
  }
35538
35537
  getCellStyle(position) {
35539
35538
  return this.getters.getCell(position)?.style || {};
@@ -35713,8 +35712,10 @@ class CellPlugin extends CorePlugin {
35713
35712
  style,
35714
35713
  format,
35715
35714
  isFormula: true,
35716
- compiledFormula,
35717
- dependencies: [],
35715
+ compiledFormula: {
35716
+ ...compiledFormula,
35717
+ dependencies: [],
35718
+ },
35718
35719
  };
35719
35720
  }
35720
35721
  /**
@@ -35723,7 +35724,7 @@ class CellPlugin extends CorePlugin {
35723
35724
  */
35724
35725
  createFormulaCellWithDependencies(id, compiledFormula, format, style, sheetId) {
35725
35726
  const dependencies = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
35726
- return new FormulaCellWithDependencies(id, compiledFormula, format, style, dependencies, sheetId, this.getFormulaCellContent.bind(this));
35727
+ return new FormulaCellWithDependencies(id, compiledFormula, format, style, dependencies, sheetId, this.getters.getRangeString.bind(this));
35727
35728
  }
35728
35729
  createErrorFormula(id, content, format, style, error) {
35729
35730
  return {
@@ -35733,13 +35734,12 @@ class CellPlugin extends CorePlugin {
35733
35734
  format,
35734
35735
  isFormula: true,
35735
35736
  compiledFormula: {
35736
- dependencies: [],
35737
35737
  tokens: tokenize(content),
35738
+ dependencies: [],
35738
35739
  execute: function () {
35739
35740
  throw error;
35740
35741
  },
35741
35742
  },
35742
- dependencies: [],
35743
35743
  };
35744
35744
  }
35745
35745
  checkCellOutOfSheet(sheetId, col, row) {
@@ -35752,27 +35752,44 @@ class CellPlugin extends CorePlugin {
35752
35752
  }
35753
35753
  class FormulaCellWithDependencies {
35754
35754
  id;
35755
- compiledFormula;
35756
35755
  format;
35757
35756
  style;
35758
- dependencies;
35759
35757
  sheetId;
35760
- getFormulaCellContent;
35758
+ getRangeString;
35761
35759
  isFormula = true;
35762
- constructor(id, compiledFormula, format, style, dependencies, sheetId, getFormulaCellContent) {
35760
+ compiledFormula;
35761
+ constructor(id, compiledFormula, format, style, dependencies, sheetId, getRangeString) {
35763
35762
  this.id = id;
35764
- this.compiledFormula = compiledFormula;
35765
35763
  this.format = format;
35766
35764
  this.style = style;
35767
- this.dependencies = dependencies;
35768
35765
  this.sheetId = sheetId;
35769
- this.getFormulaCellContent = getFormulaCellContent;
35766
+ this.getRangeString = getRangeString;
35767
+ let rangeIndex = 0;
35768
+ const tokens = compiledFormula.tokens.map((token) => {
35769
+ if (token.type === "REFERENCE") {
35770
+ const index = rangeIndex++;
35771
+ return new RangeReferenceToken(() => this.getRangeString(dependencies[index], this.sheetId));
35772
+ }
35773
+ return token;
35774
+ });
35775
+ this.compiledFormula = {
35776
+ ...compiledFormula,
35777
+ dependencies,
35778
+ tokens,
35779
+ };
35770
35780
  }
35771
35781
  get content() {
35772
- return this.getFormulaCellContent(this.sheetId, {
35773
- dependencies: this.dependencies,
35774
- compiledFormula: this.compiledFormula,
35775
- });
35782
+ return concat(this.compiledFormula.tokens.map((token) => token.value));
35783
+ }
35784
+ }
35785
+ class RangeReferenceToken {
35786
+ getValue;
35787
+ type = "REFERENCE";
35788
+ constructor(getValue) {
35789
+ this.getValue = getValue;
35790
+ }
35791
+ get value() {
35792
+ return this.getValue();
35776
35793
  }
35777
35794
  }
35778
35795
 
@@ -36917,6 +36934,13 @@ class FiltersPlugin extends CorePlugin {
36917
36934
  }
36918
36935
  onDeleteColumnsRows(cmd) {
36919
36936
  for (const table of this.getFilterTables(cmd.sheetId)) {
36937
+ // Remove the filter tables whose data filter headers are in the removed rows.
36938
+ if (cmd.dimension === "ROW" && cmd.elements.includes(table.zone.top)) {
36939
+ const tables = { ...this.tables[cmd.sheetId] };
36940
+ delete tables[table.id];
36941
+ this.history.update("tables", cmd.sheetId, tables);
36942
+ continue;
36943
+ }
36920
36944
  const zone = reduceZoneOnDeletion(table.zone, cmd.dimension === "COL" ? "left" : "top", cmd.elements);
36921
36945
  if (!zone) {
36922
36946
  const tables = { ...this.tables[cmd.sheetId] };
@@ -39965,6 +39989,13 @@ class Evaluator {
39965
39989
  return (this.evaluatedCells.get(this.encodePosition(position)) ||
39966
39990
  createEvaluatedCell("", { locale: this.getters.getLocale() }));
39967
39991
  }
39992
+ getSpreadPositionsOf(position) {
39993
+ const positionId = this.encodePosition(position);
39994
+ if (!this.spreadingRelations.isArrayFormula(positionId)) {
39995
+ return [];
39996
+ }
39997
+ return Array.from(this.spreadingRelations.getArrayResultPositionIds(positionId)).map(this.decodePosition.bind(this));
39998
+ }
39968
39999
  getArrayFormulaSpreadingOn(position) {
39969
40000
  const positionId = this.encodePosition(position);
39970
40001
  const formulaPosition = this.getArrayFormulaSpreadingOnId(positionId);
@@ -40123,7 +40154,7 @@ class Evaluator {
40123
40154
  const position = this.compilationParams[2].getters.getCellPosition(cellId);
40124
40155
  return toXC(position.col, position.row);
40125
40156
  };
40126
- const formulaReturn = cellData.compiledFormula.execute(cellData.dependencies, ...this.compilationParams);
40157
+ const formulaReturn = cellData.compiledFormula.execute(cellData.compiledFormula.dependencies, ...this.compilationParams);
40127
40158
  if (!isMatrix(formulaReturn)) {
40128
40159
  return createEvaluatedCell(formulaReturn.value, {
40129
40160
  format: cellData.format || formulaReturn.format,
@@ -40223,7 +40254,7 @@ class Evaluator {
40223
40254
  return [];
40224
40255
  }
40225
40256
  const dependencies = [];
40226
- for (const range of cell.dependencies) {
40257
+ for (const range of cell.compiledFormula.dependencies) {
40227
40258
  if (range.invalidSheetName || range.invalidXc) {
40228
40259
  continue;
40229
40260
  }
@@ -40429,6 +40460,7 @@ class EvaluationPlugin extends UIPlugin {
40429
40460
  "getEvaluatedCell",
40430
40461
  "getEvaluatedCells",
40431
40462
  "getEvaluatedCellsInZone",
40463
+ "getSpreadPositionsOf",
40432
40464
  ];
40433
40465
  shouldRebuildDependenciesGraph = true;
40434
40466
  evaluator;
@@ -40538,6 +40570,9 @@ class EvaluationPlugin extends UIPlugin {
40538
40570
  getEvaluatedCellsInZone(sheetId, zone) {
40539
40571
  return positions(zone).map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId, col, row }));
40540
40572
  }
40573
+ getSpreadPositionsOf(position) {
40574
+ return this.evaluator.getSpreadPositionsOf(position);
40575
+ }
40541
40576
  // ---------------------------------------------------------------------------
40542
40577
  // Export
40543
40578
  // ---------------------------------------------------------------------------
@@ -40575,10 +40610,10 @@ class EvaluationPlugin extends UIPlugin {
40575
40610
  */
40576
40611
  getCorrespondingFormulaCell(position) {
40577
40612
  const cell = this.getters.getCell(position);
40578
- if (cell && cell.content) {
40579
- if (cell.isFormula && !isBadExpression(cell.content)) {
40580
- return cell;
40581
- }
40613
+ if (cell && cell.isFormula) {
40614
+ return isBadExpression(cell.compiledFormula.tokens) ? undefined : cell;
40615
+ }
40616
+ else if (cell && cell.content) {
40582
40617
  return undefined;
40583
40618
  }
40584
40619
  const spreadingFormulaPosition = this.evaluator.getArrayFormulaSpreadingOn(position);
@@ -40595,9 +40630,9 @@ class EvaluationPlugin extends UIPlugin {
40595
40630
  return buildCompilationParameters(this.config.custom, this.getters, (position) => this.evaluator.getEvaluatedCell(position));
40596
40631
  }
40597
40632
  }
40598
- function isBadExpression(formula) {
40633
+ function isBadExpression(tokens) {
40599
40634
  try {
40600
- compile(formula);
40635
+ compileTokens(tokens);
40601
40636
  return false;
40602
40637
  }
40603
40638
  catch (error) {
@@ -40766,22 +40801,20 @@ class EvaluationChartPlugin extends UIPlugin {
40766
40801
  invalidateCFEvaluationCommands.has(cmd.type) ||
40767
40802
  cmd.type === "EVALUATE_CELLS" ||
40768
40803
  cmd.type === "UPDATE_CELL") {
40769
- if (cmd.type !== "UNDO" && cmd.type !== "REDO") {
40770
- for (const chartId in this.charts) {
40771
- this.history.update("charts", chartId, undefined);
40772
- }
40804
+ for (const chartId in this.charts) {
40805
+ this.charts[chartId] = undefined;
40773
40806
  }
40774
40807
  }
40775
40808
  switch (cmd.type) {
40776
40809
  case "UPDATE_CHART":
40777
40810
  case "CREATE_CHART":
40778
40811
  case "DELETE_FIGURE":
40779
- this.history.update("charts", cmd.id, undefined);
40812
+ this.charts[cmd.id] = undefined;
40780
40813
  break;
40781
40814
  case "DELETE_SHEET":
40782
40815
  for (let chartId in this.charts) {
40783
40816
  if (!this.getters.isChartDefined(chartId)) {
40784
- this.history.update("charts", chartId, undefined);
40817
+ this.charts[chartId] = undefined;
40785
40818
  }
40786
40819
  }
40787
40820
  break;
@@ -40793,8 +40826,7 @@ class EvaluationChartPlugin extends UIPlugin {
40793
40826
  if (!chart) {
40794
40827
  throw new Error(`No chart for the given id: ${figureId}`);
40795
40828
  }
40796
- const runtime = this.createRuntimeChart(chart);
40797
- this.history.update("charts", figureId, runtime);
40829
+ this.charts[figureId] = this.createRuntimeChart(chart);
40798
40830
  }
40799
40831
  return this.charts[figureId];
40800
40832
  }
@@ -40946,7 +40978,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
40946
40978
  const values = cf.rule.values.map((value, i) => {
40947
40979
  const compiledFormula = formulas[i];
40948
40980
  if (compiledFormula) {
40949
- return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top, compiledFormula, compiledFormula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)));
40981
+ return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top, {
40982
+ ...compiledFormula,
40983
+ dependencies: compiledFormula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
40984
+ });
40950
40985
  }
40951
40986
  return value;
40952
40987
  });
@@ -41318,7 +41353,10 @@ class EvaluationDataValidationPlugin extends UIPlugin {
41318
41353
  }
41319
41354
  try {
41320
41355
  const formula = compile(value);
41321
- const translatedFormula = this.getters.getTranslatedCellFormula(sheetId, offset.col, offset.row, formula, formula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)));
41356
+ const translatedFormula = this.getters.getTranslatedCellFormula(sheetId, offset.col, offset.row, {
41357
+ ...formula,
41358
+ dependencies: formula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
41359
+ });
41322
41360
  const evaluated = this.getters.evaluateFormula(sheetId, translatedFormula);
41323
41361
  return evaluated && !isMatrix(evaluated) ? evaluated.toString() : "";
41324
41362
  }
@@ -43570,7 +43608,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
43570
43608
  }
43571
43609
  let content = origin.cell.content;
43572
43610
  if (origin.cell.isFormula && operation === "COPY") {
43573
- content = this.getters.getTranslatedCellFormula(sheetId, col - origin.position.col, row - origin.position.row, origin.cell.compiledFormula, origin.cell.dependencies);
43611
+ content = this.getters.getTranslatedCellFormula(sheetId, col - origin.position.col, row - origin.position.row, origin.cell.compiledFormula);
43574
43612
  }
43575
43613
  this.dispatch("UPDATE_CELL", {
43576
43614
  ...target,
@@ -44102,20 +44140,29 @@ class FindAndReplacePlugin extends UIPlugin {
44102
44140
  const sheetId = this.getters.getActiveSheetId();
44103
44141
  const cells = this.getters.getCells(sheetId);
44104
44142
  const matches = [];
44105
- if (this.toSearch) {
44143
+ if (this.toSearch && this.currentSearchRegex) {
44106
44144
  for (const cell of Object.values(cells)) {
44107
44145
  const { col, row } = this.getters.getCellPosition(cell.id);
44146
+ const cellPosition = { sheetId, col, row };
44108
44147
  const isColHidden = this.getters.isColHidden(sheetId, col);
44109
44148
  const isRowHidden = this.getters.isRowHidden(sheetId, row);
44110
44149
  if (isColHidden || isRowHidden) {
44111
44150
  continue;
44112
44151
  }
44113
- if (cell &&
44114
- this.currentSearchRegex &&
44115
- this.currentSearchRegex.test(this.getSearchableString({ sheetId, col, row }))) {
44152
+ if (this.currentSearchRegex.test(this.getSearchableString(cellPosition))) {
44116
44153
  const match = { col, row, selected: false };
44117
44154
  matches.push(match);
44118
44155
  }
44156
+ for (const spreadPosition of this.getters.getSpreadPositionsOf(cellPosition)) {
44157
+ if (this.currentSearchRegex.test(this.getSearchableString(spreadPosition))) {
44158
+ const match = {
44159
+ col: spreadPosition.col,
44160
+ row: spreadPosition.row,
44161
+ selected: false,
44162
+ };
44163
+ matches.push(match);
44164
+ }
44165
+ }
44119
44166
  }
44120
44167
  }
44121
44168
  return matches.sort(this.sortByRowThenColumn);
@@ -44174,16 +44221,19 @@ class FindAndReplacePlugin extends UIPlugin {
44174
44221
  return;
44175
44222
  }
44176
44223
  const sheetId = this.getters.getActiveSheetId();
44177
- const cell = this.getters.getCell({ sheetId, ...selectedMatch });
44178
- const { col, row } = selectedMatch;
44224
+ const position = { sheetId, ...selectedMatch };
44225
+ const cell = this.getters.getCell(position);
44226
+ if (!cell?.content) {
44227
+ return;
44228
+ }
44179
44229
  if (cell?.isFormula && !this.searchOptions.searchFormulas) {
44180
44230
  return;
44181
44231
  }
44182
44232
  const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
44183
- const toReplace = this.getSearchableString({ sheetId, col, row });
44233
+ const toReplace = this.getSearchableString(position);
44184
44234
  const content = toReplace.replace(replaceRegex, replaceWith);
44185
44235
  const canonicalContent = canonicalizeNumberContent(content, this.getters.getLocale());
44186
- this.dispatch("UPDATE_CELL", { sheetId, col, row, content: canonicalContent });
44236
+ this.dispatch("UPDATE_CELL", { ...position, content: canonicalContent });
44187
44237
  }
44188
44238
  /**
44189
44239
  * Replace the value of the currently selected match
@@ -45758,7 +45808,7 @@ class SortPlugin extends UIPlugin {
45758
45808
  if (cell.isFormula) {
45759
45809
  const position = this.getters.getCellPosition(cell.id);
45760
45810
  // we only have a vertical offset
45761
- content = this.getters.getTranslatedCellFormula(sheetId, 0, newRow - position.row, cell.compiledFormula, cell.dependencies);
45811
+ content = this.getters.getTranslatedCellFormula(sheetId, 0, newRow - position.row, cell.compiledFormula);
45762
45812
  }
45763
45813
  newCellValues.style = cell.style;
45764
45814
  newCellValues.content = content;
@@ -47821,6 +47871,8 @@ class FilterEvaluationPlugin extends UIPlugin {
47821
47871
  case "EVALUATE_CELLS":
47822
47872
  case "ACTIVATE_SHEET":
47823
47873
  case "REMOVE_FILTER_TABLE":
47874
+ case "ADD_COLUMNS_ROWS":
47875
+ case "REMOVE_COLUMNS_ROWS":
47824
47876
  this.isEvaluationDirty = true;
47825
47877
  break;
47826
47878
  case "START":
@@ -55844,6 +55896,7 @@ exports.__info__ = __info__;
55844
55896
  exports.addFunction = addFunction;
55845
55897
  exports.astToFormula = astToFormula;
55846
55898
  exports.compile = compile;
55899
+ exports.compileTokens = compileTokens;
55847
55900
  exports.components = components;
55848
55901
  exports.constants = constants;
55849
55902
  exports.convertAstNodes = convertAstNodes;
@@ -55859,6 +55912,7 @@ exports.iterateAstNodes = iterateAstNodes;
55859
55912
  exports.links = links;
55860
55913
  exports.load = load;
55861
55914
  exports.parse = parse;
55915
+ exports.parseTokens = parseTokens;
55862
55916
  exports.readonlyAllowedCommands = readonlyAllowedCommands;
55863
55917
  exports.registries = registries;
55864
55918
  exports.setDefaultSheetViewSize = setDefaultSheetViewSize;
@@ -55866,6 +55920,6 @@ exports.setTranslationMethod = setTranslationMethod;
55866
55920
  exports.tokenize = tokenize;
55867
55921
 
55868
55922
 
55869
- __info__.version = "17.0.2";
55870
- __info__.date = "2023-11-03T12:22:44.945Z";
55871
- __info__.hash = "3184728";
55923
+ __info__.version = "17.0.3";
55924
+ __info__.date = "2023-11-16T11:59:49.524Z";
55925
+ __info__.hash = "8bd0fb2";
@@ -17,6 +17,7 @@ declare const functionCache: {
17
17
  [key: string]: Omit<CompiledFormula, "dependencies" | "tokens">;
18
18
  };
19
19
  declare function compile(formula: string): CompiledFormula;
20
+ declare function compileTokens(tokens: Token[]): CompiledFormula;
20
21
 
21
22
  interface FunctionContext {
22
23
  parent: string;
@@ -93,6 +94,7 @@ type AST = ASTOperation | ASTUnaryOperation | ASTFuncall | ASTNumber | ASTBoolea
93
94
  * Parse an expression (as a string) into an AST.
94
95
  */
95
96
  declare function parse(str: string): AST;
97
+ declare function parseTokens(tokens: Token[]): AST;
96
98
  /**
97
99
  * Allows to visit all nodes of an AST and apply a mapping function
98
100
  * to nodes of a specific type.
@@ -2652,6 +2654,9 @@ interface CompiledFormula {
2652
2654
  tokens: Token[];
2653
2655
  dependencies: string[];
2654
2656
  }
2657
+ interface RangeCompiledFormula extends Omit<CompiledFormula, "dependencies"> {
2658
+ dependencies: Range[];
2659
+ }
2655
2660
  type Matrix<T = unknown> = T[][];
2656
2661
  type ValueAndFormat = {
2657
2662
  value: CellValue;
@@ -2803,8 +2808,7 @@ interface LiteralCell extends CellAttributes {
2803
2808
  }
2804
2809
  interface FormulaCell extends CellAttributes {
2805
2810
  readonly isFormula: true;
2806
- readonly compiledFormula: CompiledFormula;
2807
- readonly dependencies: Range[];
2811
+ readonly compiledFormula: RangeCompiledFormula;
2808
2812
  }
2809
2813
  type Cell = LiteralCell | FormulaCell;
2810
2814
  interface EvaluatedCellProperties {
@@ -3378,8 +3382,8 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
3378
3382
  * starting an async evaluation even if it has been moved or re-allocated
3379
3383
  */
3380
3384
  getCellById(cellId: UID): Cell | undefined;
3381
- getFormulaCellContent(sheetId: UID, cell: Pick<FormulaCell, "dependencies" | "compiledFormula">, dependencies?: Range[]): string;
3382
- getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: CompiledFormula, dependencies: Range[]): string;
3385
+ getFormulaCellContent(sheetId: UID, compiledFormula: RangeCompiledFormula, dependencies?: Range[]): string;
3386
+ getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: RangeCompiledFormula): string;
3383
3387
  getCellStyle(position: CellPosition): Style;
3384
3388
  /**
3385
3389
  * Converts a zone to a XC coordinate system
@@ -4084,7 +4088,7 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
4084
4088
 
4085
4089
  declare class EvaluationPlugin extends UIPlugin {
4086
4090
  private config;
4087
- static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone"];
4091
+ static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf"];
4088
4092
  private shouldRebuildDependenciesGraph;
4089
4093
  private evaluator;
4090
4094
  private compilationParams;
@@ -4109,6 +4113,7 @@ declare class EvaluationPlugin extends UIPlugin {
4109
4113
  getEvaluatedCell(position: CellPosition): EvaluatedCell;
4110
4114
  getEvaluatedCells(sheetId: UID): Record<UID, EvaluatedCell>;
4111
4115
  getEvaluatedCellsInZone(sheetId: UID, zone: Zone): EvaluatedCell[];
4116
+ getSpreadPositionsOf(position: CellPosition): CellPosition[];
4112
4117
  exportForExcel(data: ExcelWorkbookData): void;
4113
4118
  /**
4114
4119
  * Returns the corresponding formula cell of a given cell
@@ -4142,11 +4147,11 @@ declare class CustomColorsPlugin extends UIPlugin<CustomColorState> {
4142
4147
  }
4143
4148
 
4144
4149
  interface EvaluationChartState {
4145
- readonly charts: Immutable<Record<UID, ChartRuntime | undefined>>;
4150
+ charts: Record<UID, ChartRuntime | undefined>;
4146
4151
  }
4147
4152
  declare class EvaluationChartPlugin extends UIPlugin<EvaluationChartState> {
4148
4153
  static getters: readonly ["getChartRuntime", "getBackgroundOfSingleCellChart"];
4149
- readonly charts: Immutable<Record<UID, ChartRuntime | undefined>>;
4154
+ charts: Record<UID, ChartRuntime | undefined>;
4150
4155
  private createRuntimeChart;
4151
4156
  handle(cmd: CoreViewCommand): void;
4152
4157
  getChartRuntime(figureId: UID): ChartRuntime;
@@ -7908,4 +7913,4 @@ declare const constants: {
7908
7913
  DEFAULT_LOCALE: Locale;
7909
7914
  };
7910
7915
 
7911
- export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
7916
+ export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };