@odoo/o-spreadsheet 16.3.13 → 16.3.15

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.
@@ -4433,6 +4433,9 @@ exports.CommandResult = void 0;
4433
4433
  })(exports.CommandResult || (exports.CommandResult = {}));
4434
4434
 
4435
4435
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4436
+ function isMatrix(x) {
4437
+ return Array.isArray(x) && Array.isArray(x[0]);
4438
+ }
4436
4439
  var DIRECTION;
4437
4440
  (function (DIRECTION) {
4438
4441
  DIRECTION["UP"] = "up";
@@ -15358,6 +15361,35 @@ const HLOOKUP = {
15358
15361
  isExported: true,
15359
15362
  };
15360
15363
  // -----------------------------------------------------------------------------
15364
+ // INDEX
15365
+ // -----------------------------------------------------------------------------
15366
+ const INDEX = {
15367
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15368
+ args: [
15369
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15370
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15371
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15372
+ ],
15373
+ returns: ["ANY"],
15374
+ computeFormat: (reference, row, column) => {
15375
+ const _row = toNumber(row.value);
15376
+ const _column = toNumber(column.value);
15377
+ return reference[_column - 1][_row - 1]?.format;
15378
+ },
15379
+ compute: function (reference, row, column) {
15380
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15381
+ const _row = toNumber(row);
15382
+ const _column = toNumber(column);
15383
+ assert(() => _column >= 0 &&
15384
+ _column - 1 < _reference.length &&
15385
+ _row >= 0 &&
15386
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15387
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15388
+ return _reference[_column - 1][_row - 1];
15389
+ },
15390
+ isExported: true,
15391
+ };
15392
+ // -----------------------------------------------------------------------------
15361
15393
  // LOOKUP
15362
15394
  // -----------------------------------------------------------------------------
15363
15395
  const LOOKUP = {
@@ -15552,6 +15584,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15552
15584
  COLUMN: COLUMN,
15553
15585
  COLUMNS: COLUMNS,
15554
15586
  HLOOKUP: HLOOKUP,
15587
+ INDEX: INDEX,
15555
15588
  LOOKUP: LOOKUP,
15556
15589
  MATCH: MATCH,
15557
15590
  ROW: ROW,
@@ -20447,7 +20480,7 @@ class ClientTag extends owl.Component {
20447
20480
  left: `${x - 1}px`,
20448
20481
  border: `1px solid ${color}`,
20449
20482
  "background-color": color,
20450
- opacity: this.props.active ? "opacity:1 !important" : undefined,
20483
+ opacity: this.props.active ? "1 !important" : undefined,
20451
20484
  });
20452
20485
  }
20453
20486
  }
@@ -26989,12 +27022,15 @@ function createXMLFile(doc, path, contentType) {
26989
27022
  };
26990
27023
  }
26991
27024
  function xmlEscape(str) {
26992
- return String(str)
27025
+ return (String(str)
26993
27026
  .replace(/\&/g, "&amp;")
26994
27027
  .replace(/\</g, "&lt;")
26995
27028
  .replace(/\>/g, "&gt;")
26996
27029
  .replace(/\"/g, "&quot;")
26997
- .replace(/\'/g, "&apos;");
27030
+ .replace(/\'/g, "&apos;")
27031
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27032
+ // They are not valid at all in XML 1.0 (even escaped)
27033
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26998
27034
  }
26999
27035
  function formatAttributes(attrs) {
27000
27036
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34084,6 +34120,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34084
34120
  }
34085
34121
  currentRanges = currentRanges.concat(toAdd);
34086
34122
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34123
+ if (newRangesXC.length === 0) {
34124
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34125
+ return;
34126
+ }
34087
34127
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34088
34128
  cf: {
34089
34129
  id: cf.id,
@@ -41512,11 +41552,19 @@ class GridSelectionPlugin extends UIPlugin {
41512
41552
  }
41513
41553
  }
41514
41554
  getStatisticFnResults() {
41515
- // get deduplicated cells in zones
41516
- const cells = new Set(this.gridSelection.zones
41517
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
41518
- .flat()
41519
- .filter((cell) => cell.type !== CellValueType.empty));
41555
+ const sheetId = this.getters.getActiveSheetId();
41556
+ const cells = new Set();
41557
+ for (const zone of this.gridSelection.zones) {
41558
+ for (const { col, row } of positions(zone)) {
41559
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
41560
+ continue; // Skip hidden cells
41561
+ }
41562
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
41563
+ if (evaluatedCell.type !== CellValueType.empty) {
41564
+ cells.add(evaluatedCell);
41565
+ }
41566
+ }
41567
+ }
41520
41568
  let cellsTypes = new Set();
41521
41569
  let cellsValues = [];
41522
41570
  for (let cell of cells) {
@@ -43181,6 +43229,7 @@ const BORDER_POSITIONS = [
43181
43229
  css /* scss */ `
43182
43230
  .o-border-selector {
43183
43231
  padding: 4px;
43232
+ background-color: white;
43184
43233
  }
43185
43234
  .o-divider {
43186
43235
  border-right: 1px solid #e0e2e4;
@@ -47746,6 +47795,6 @@ exports.setTranslationMethod = setTranslationMethod;
47746
47795
  exports.tokenize = tokenize;
47747
47796
 
47748
47797
 
47749
- __info__.version = '16.3.13';
47750
- __info__.date = '2023-10-10T07:28:39.702Z';
47751
- __info__.hash = '67b6363';
47798
+ __info__.version = '16.3.15';
47799
+ __info__.date = '2023-10-25T10:03:43.272Z';
47800
+ __info__.hash = 'fb7c4dd';
@@ -4429,6 +4429,9 @@ var CommandResult;
4429
4429
  })(CommandResult || (CommandResult = {}));
4430
4430
 
4431
4431
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4432
+ function isMatrix(x) {
4433
+ return Array.isArray(x) && Array.isArray(x[0]);
4434
+ }
4432
4435
  var DIRECTION;
4433
4436
  (function (DIRECTION) {
4434
4437
  DIRECTION["UP"] = "up";
@@ -15354,6 +15357,35 @@ const HLOOKUP = {
15354
15357
  isExported: true,
15355
15358
  };
15356
15359
  // -----------------------------------------------------------------------------
15360
+ // INDEX
15361
+ // -----------------------------------------------------------------------------
15362
+ const INDEX = {
15363
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15364
+ args: [
15365
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15366
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15367
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15368
+ ],
15369
+ returns: ["ANY"],
15370
+ computeFormat: (reference, row, column) => {
15371
+ const _row = toNumber(row.value);
15372
+ const _column = toNumber(column.value);
15373
+ return reference[_column - 1][_row - 1]?.format;
15374
+ },
15375
+ compute: function (reference, row, column) {
15376
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15377
+ const _row = toNumber(row);
15378
+ const _column = toNumber(column);
15379
+ assert(() => _column >= 0 &&
15380
+ _column - 1 < _reference.length &&
15381
+ _row >= 0 &&
15382
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15383
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15384
+ return _reference[_column - 1][_row - 1];
15385
+ },
15386
+ isExported: true,
15387
+ };
15388
+ // -----------------------------------------------------------------------------
15357
15389
  // LOOKUP
15358
15390
  // -----------------------------------------------------------------------------
15359
15391
  const LOOKUP = {
@@ -15548,6 +15580,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15548
15580
  COLUMN: COLUMN,
15549
15581
  COLUMNS: COLUMNS,
15550
15582
  HLOOKUP: HLOOKUP,
15583
+ INDEX: INDEX,
15551
15584
  LOOKUP: LOOKUP,
15552
15585
  MATCH: MATCH,
15553
15586
  ROW: ROW,
@@ -20443,7 +20476,7 @@ class ClientTag extends Component {
20443
20476
  left: `${x - 1}px`,
20444
20477
  border: `1px solid ${color}`,
20445
20478
  "background-color": color,
20446
- opacity: this.props.active ? "opacity:1 !important" : undefined,
20479
+ opacity: this.props.active ? "1 !important" : undefined,
20447
20480
  });
20448
20481
  }
20449
20482
  }
@@ -26985,12 +27018,15 @@ function createXMLFile(doc, path, contentType) {
26985
27018
  };
26986
27019
  }
26987
27020
  function xmlEscape(str) {
26988
- return String(str)
27021
+ return (String(str)
26989
27022
  .replace(/\&/g, "&amp;")
26990
27023
  .replace(/\</g, "&lt;")
26991
27024
  .replace(/\>/g, "&gt;")
26992
27025
  .replace(/\"/g, "&quot;")
26993
- .replace(/\'/g, "&apos;");
27026
+ .replace(/\'/g, "&apos;")
27027
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27028
+ // They are not valid at all in XML 1.0 (even escaped)
27029
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26994
27030
  }
26995
27031
  function formatAttributes(attrs) {
26996
27032
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34080,6 +34116,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34080
34116
  }
34081
34117
  currentRanges = currentRanges.concat(toAdd);
34082
34118
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34119
+ if (newRangesXC.length === 0) {
34120
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34121
+ return;
34122
+ }
34083
34123
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34084
34124
  cf: {
34085
34125
  id: cf.id,
@@ -41508,11 +41548,19 @@ class GridSelectionPlugin extends UIPlugin {
41508
41548
  }
41509
41549
  }
41510
41550
  getStatisticFnResults() {
41511
- // get deduplicated cells in zones
41512
- const cells = new Set(this.gridSelection.zones
41513
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
41514
- .flat()
41515
- .filter((cell) => cell.type !== CellValueType.empty));
41551
+ const sheetId = this.getters.getActiveSheetId();
41552
+ const cells = new Set();
41553
+ for (const zone of this.gridSelection.zones) {
41554
+ for (const { col, row } of positions(zone)) {
41555
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
41556
+ continue; // Skip hidden cells
41557
+ }
41558
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
41559
+ if (evaluatedCell.type !== CellValueType.empty) {
41560
+ cells.add(evaluatedCell);
41561
+ }
41562
+ }
41563
+ }
41516
41564
  let cellsTypes = new Set();
41517
41565
  let cellsValues = [];
41518
41566
  for (let cell of cells) {
@@ -43177,6 +43225,7 @@ const BORDER_POSITIONS = [
43177
43225
  css /* scss */ `
43178
43226
  .o-border-selector {
43179
43227
  padding: 4px;
43228
+ background-color: white;
43180
43229
  }
43181
43230
  .o-divider {
43182
43231
  border-right: 1px solid #e0e2e4;
@@ -47714,6 +47763,6 @@ function addFunction(functionName, functionDescription) {
47714
47763
  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 };
47715
47764
 
47716
47765
 
47717
- __info__.version = '16.3.13';
47718
- __info__.date = '2023-10-10T07:28:39.702Z';
47719
- __info__.hash = '67b6363';
47766
+ __info__.version = '16.3.15';
47767
+ __info__.date = '2023-10-25T10:03:43.272Z';
47768
+ __info__.hash = 'fb7c4dd';
@@ -4430,6 +4430,9 @@
4430
4430
  })(exports.CommandResult || (exports.CommandResult = {}));
4431
4431
 
4432
4432
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4433
+ function isMatrix(x) {
4434
+ return Array.isArray(x) && Array.isArray(x[0]);
4435
+ }
4433
4436
  var DIRECTION;
4434
4437
  (function (DIRECTION) {
4435
4438
  DIRECTION["UP"] = "up";
@@ -15355,6 +15358,35 @@
15355
15358
  isExported: true,
15356
15359
  };
15357
15360
  // -----------------------------------------------------------------------------
15361
+ // INDEX
15362
+ // -----------------------------------------------------------------------------
15363
+ const INDEX = {
15364
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15365
+ args: [
15366
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15367
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15368
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15369
+ ],
15370
+ returns: ["ANY"],
15371
+ computeFormat: (reference, row, column) => {
15372
+ const _row = toNumber(row.value);
15373
+ const _column = toNumber(column.value);
15374
+ return reference[_column - 1][_row - 1]?.format;
15375
+ },
15376
+ compute: function (reference, row, column) {
15377
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15378
+ const _row = toNumber(row);
15379
+ const _column = toNumber(column);
15380
+ assert(() => _column >= 0 &&
15381
+ _column - 1 < _reference.length &&
15382
+ _row >= 0 &&
15383
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15384
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15385
+ return _reference[_column - 1][_row - 1];
15386
+ },
15387
+ isExported: true,
15388
+ };
15389
+ // -----------------------------------------------------------------------------
15358
15390
  // LOOKUP
15359
15391
  // -----------------------------------------------------------------------------
15360
15392
  const LOOKUP = {
@@ -15549,6 +15581,7 @@
15549
15581
  COLUMN: COLUMN,
15550
15582
  COLUMNS: COLUMNS,
15551
15583
  HLOOKUP: HLOOKUP,
15584
+ INDEX: INDEX,
15552
15585
  LOOKUP: LOOKUP,
15553
15586
  MATCH: MATCH,
15554
15587
  ROW: ROW,
@@ -20444,7 +20477,7 @@
20444
20477
  left: `${x - 1}px`,
20445
20478
  border: `1px solid ${color}`,
20446
20479
  "background-color": color,
20447
- opacity: this.props.active ? "opacity:1 !important" : undefined,
20480
+ opacity: this.props.active ? "1 !important" : undefined,
20448
20481
  });
20449
20482
  }
20450
20483
  }
@@ -26986,12 +27019,15 @@
26986
27019
  };
26987
27020
  }
26988
27021
  function xmlEscape(str) {
26989
- return String(str)
27022
+ return (String(str)
26990
27023
  .replace(/\&/g, "&amp;")
26991
27024
  .replace(/\</g, "&lt;")
26992
27025
  .replace(/\>/g, "&gt;")
26993
27026
  .replace(/\"/g, "&quot;")
26994
- .replace(/\'/g, "&apos;");
27027
+ .replace(/\'/g, "&apos;")
27028
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27029
+ // They are not valid at all in XML 1.0 (even escaped)
27030
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26995
27031
  }
26996
27032
  function formatAttributes(attrs) {
26997
27033
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34081,6 +34117,10 @@
34081
34117
  }
34082
34118
  currentRanges = currentRanges.concat(toAdd);
34083
34119
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34120
+ if (newRangesXC.length === 0) {
34121
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34122
+ return;
34123
+ }
34084
34124
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34085
34125
  cf: {
34086
34126
  id: cf.id,
@@ -41509,11 +41549,19 @@
41509
41549
  }
41510
41550
  }
41511
41551
  getStatisticFnResults() {
41512
- // get deduplicated cells in zones
41513
- const cells = new Set(this.gridSelection.zones
41514
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
41515
- .flat()
41516
- .filter((cell) => cell.type !== CellValueType.empty));
41552
+ const sheetId = this.getters.getActiveSheetId();
41553
+ const cells = new Set();
41554
+ for (const zone of this.gridSelection.zones) {
41555
+ for (const { col, row } of positions(zone)) {
41556
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
41557
+ continue; // Skip hidden cells
41558
+ }
41559
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
41560
+ if (evaluatedCell.type !== CellValueType.empty) {
41561
+ cells.add(evaluatedCell);
41562
+ }
41563
+ }
41564
+ }
41517
41565
  let cellsTypes = new Set();
41518
41566
  let cellsValues = [];
41519
41567
  for (let cell of cells) {
@@ -43178,6 +43226,7 @@
43178
43226
  css /* scss */ `
43179
43227
  .o-border-selector {
43180
43228
  padding: 4px;
43229
+ background-color: white;
43181
43230
  }
43182
43231
  .o-divider {
43183
43232
  border-right: 1px solid #e0e2e4;
@@ -47745,9 +47794,9 @@
47745
47794
  Object.defineProperty(exports, '__esModule', { value: true });
47746
47795
 
47747
47796
 
47748
- __info__.version = '16.3.13';
47749
- __info__.date = '2023-10-10T07:28:39.702Z';
47750
- __info__.hash = '67b6363';
47797
+ __info__.version = '16.3.15';
47798
+ __info__.date = '2023-10-25T10:03:43.272Z';
47799
+ __info__.hash = 'fb7c4dd';
47751
47800
 
47752
47801
 
47753
47802
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);