@odoo/o-spreadsheet 16.2.18 → 16.2.20

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.
@@ -4307,6 +4307,9 @@ exports.CommandResult = void 0;
4307
4307
  CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4308
4308
  })(exports.CommandResult || (exports.CommandResult = {}));
4309
4309
 
4310
+ function isMatrix(x) {
4311
+ return Array.isArray(x) && Array.isArray(x[0]);
4312
+ }
4310
4313
  var DIRECTION;
4311
4314
  (function (DIRECTION) {
4312
4315
  DIRECTION["UP"] = "up";
@@ -15173,6 +15176,36 @@ const HLOOKUP = {
15173
15176
  isExported: true,
15174
15177
  };
15175
15178
  // -----------------------------------------------------------------------------
15179
+ // INDEX
15180
+ // -----------------------------------------------------------------------------
15181
+ const INDEX = {
15182
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15183
+ args: [
15184
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15185
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15186
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15187
+ ],
15188
+ returns: ["ANY"],
15189
+ computeFormat: (reference, row, column) => {
15190
+ var _a;
15191
+ const _row = toNumber(row.value);
15192
+ const _column = toNumber(column.value);
15193
+ return (_a = reference[_column - 1][_row - 1]) === null || _a === void 0 ? void 0 : _a.format;
15194
+ },
15195
+ compute: function (reference, row, column) {
15196
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15197
+ const _row = toNumber(row);
15198
+ const _column = toNumber(column);
15199
+ assert(() => _column >= 0 &&
15200
+ _column - 1 < _reference.length &&
15201
+ _row >= 0 &&
15202
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15203
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15204
+ return _reference[_column - 1][_row - 1];
15205
+ },
15206
+ isExported: true,
15207
+ };
15208
+ // -----------------------------------------------------------------------------
15176
15209
  // LOOKUP
15177
15210
  // -----------------------------------------------------------------------------
15178
15211
  const LOOKUP = {
@@ -15367,6 +15400,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15367
15400
  COLUMN: COLUMN,
15368
15401
  COLUMNS: COLUMNS,
15369
15402
  HLOOKUP: HLOOKUP,
15403
+ INDEX: INDEX,
15370
15404
  LOOKUP: LOOKUP,
15371
15405
  MATCH: MATCH,
15372
15406
  ROW: ROW,
@@ -19364,7 +19398,7 @@ class ClientTag extends owl.Component {
19364
19398
  left: `${x - 1}px`,
19365
19399
  border: `1px solid ${color}`,
19366
19400
  "background-color": color,
19367
- opacity: this.props.active ? "opacity:1 !important" : undefined,
19401
+ opacity: this.props.active ? "1 !important" : undefined,
19368
19402
  });
19369
19403
  }
19370
19404
  }
@@ -25526,12 +25560,15 @@ function createXMLFile(doc, path, contentType) {
25526
25560
  };
25527
25561
  }
25528
25562
  function xmlEscape(str) {
25529
- return String(str)
25563
+ return (String(str)
25530
25564
  .replace(/\&/g, "&amp;")
25531
25565
  .replace(/\</g, "&lt;")
25532
25566
  .replace(/\>/g, "&gt;")
25533
25567
  .replace(/\"/g, "&quot;")
25534
- .replace(/\'/g, "&apos;");
25568
+ .replace(/\'/g, "&apos;")
25569
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
25570
+ // They are not valid at all in XML 1.0 (even escaped)
25571
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
25535
25572
  }
25536
25573
  function formatAttributes(attrs) {
25537
25574
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -32594,6 +32631,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
32594
32631
  }
32595
32632
  currentRanges = currentRanges.concat(toAdd);
32596
32633
  const newRangesXC = recomputeZones(currentRanges, toRemove);
32634
+ if (newRangesXC.length === 0) {
32635
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
32636
+ return;
32637
+ }
32597
32638
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
32598
32639
  cf: {
32599
32640
  id: cf.id,
@@ -39339,11 +39380,19 @@ class GridSelectionPlugin extends UIPlugin {
39339
39380
  }
39340
39381
  }
39341
39382
  getStatisticFnResults() {
39342
- // get deduplicated cells in zones
39343
- const cells = new Set(this.gridSelection.zones
39344
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39345
- .flat()
39346
- .filter((cell) => cell.type !== CellValueType.empty));
39383
+ const sheetId = this.getters.getActiveSheetId();
39384
+ const cells = new Set();
39385
+ for (const zone of this.gridSelection.zones) {
39386
+ for (const { col, row } of positions(zone)) {
39387
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39388
+ continue; // Skip hidden cells
39389
+ }
39390
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39391
+ if (evaluatedCell.type !== CellValueType.empty) {
39392
+ cells.add(evaluatedCell);
39393
+ }
39394
+ }
39395
+ }
39347
39396
  let cellsTypes = new Set();
39348
39397
  let cellsValues = [];
39349
39398
  for (let cell of cells) {
@@ -45485,6 +45534,6 @@ exports.setTranslationMethod = setTranslationMethod;
45485
45534
  exports.tokenize = tokenize;
45486
45535
 
45487
45536
 
45488
- __info__.version = '16.2.18';
45489
- __info__.date = '2023-10-10T07:29:40.321Z';
45490
- __info__.hash = '451fa09';
45537
+ __info__.version = '16.2.20';
45538
+ __info__.date = '2023-10-25T10:00:14.966Z';
45539
+ __info__.hash = '25a402d';
@@ -4303,6 +4303,9 @@ var CommandResult;
4303
4303
  CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4304
4304
  })(CommandResult || (CommandResult = {}));
4305
4305
 
4306
+ function isMatrix(x) {
4307
+ return Array.isArray(x) && Array.isArray(x[0]);
4308
+ }
4306
4309
  var DIRECTION;
4307
4310
  (function (DIRECTION) {
4308
4311
  DIRECTION["UP"] = "up";
@@ -15169,6 +15172,36 @@ const HLOOKUP = {
15169
15172
  isExported: true,
15170
15173
  };
15171
15174
  // -----------------------------------------------------------------------------
15175
+ // INDEX
15176
+ // -----------------------------------------------------------------------------
15177
+ const INDEX = {
15178
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15179
+ args: [
15180
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15181
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15182
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15183
+ ],
15184
+ returns: ["ANY"],
15185
+ computeFormat: (reference, row, column) => {
15186
+ var _a;
15187
+ const _row = toNumber(row.value);
15188
+ const _column = toNumber(column.value);
15189
+ return (_a = reference[_column - 1][_row - 1]) === null || _a === void 0 ? void 0 : _a.format;
15190
+ },
15191
+ compute: function (reference, row, column) {
15192
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15193
+ const _row = toNumber(row);
15194
+ const _column = toNumber(column);
15195
+ assert(() => _column >= 0 &&
15196
+ _column - 1 < _reference.length &&
15197
+ _row >= 0 &&
15198
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15199
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15200
+ return _reference[_column - 1][_row - 1];
15201
+ },
15202
+ isExported: true,
15203
+ };
15204
+ // -----------------------------------------------------------------------------
15172
15205
  // LOOKUP
15173
15206
  // -----------------------------------------------------------------------------
15174
15207
  const LOOKUP = {
@@ -15363,6 +15396,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15363
15396
  COLUMN: COLUMN,
15364
15397
  COLUMNS: COLUMNS,
15365
15398
  HLOOKUP: HLOOKUP,
15399
+ INDEX: INDEX,
15366
15400
  LOOKUP: LOOKUP,
15367
15401
  MATCH: MATCH,
15368
15402
  ROW: ROW,
@@ -19360,7 +19394,7 @@ class ClientTag extends Component {
19360
19394
  left: `${x - 1}px`,
19361
19395
  border: `1px solid ${color}`,
19362
19396
  "background-color": color,
19363
- opacity: this.props.active ? "opacity:1 !important" : undefined,
19397
+ opacity: this.props.active ? "1 !important" : undefined,
19364
19398
  });
19365
19399
  }
19366
19400
  }
@@ -25522,12 +25556,15 @@ function createXMLFile(doc, path, contentType) {
25522
25556
  };
25523
25557
  }
25524
25558
  function xmlEscape(str) {
25525
- return String(str)
25559
+ return (String(str)
25526
25560
  .replace(/\&/g, "&amp;")
25527
25561
  .replace(/\</g, "&lt;")
25528
25562
  .replace(/\>/g, "&gt;")
25529
25563
  .replace(/\"/g, "&quot;")
25530
- .replace(/\'/g, "&apos;");
25564
+ .replace(/\'/g, "&apos;")
25565
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
25566
+ // They are not valid at all in XML 1.0 (even escaped)
25567
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
25531
25568
  }
25532
25569
  function formatAttributes(attrs) {
25533
25570
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -32590,6 +32627,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
32590
32627
  }
32591
32628
  currentRanges = currentRanges.concat(toAdd);
32592
32629
  const newRangesXC = recomputeZones(currentRanges, toRemove);
32630
+ if (newRangesXC.length === 0) {
32631
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
32632
+ return;
32633
+ }
32593
32634
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
32594
32635
  cf: {
32595
32636
  id: cf.id,
@@ -39335,11 +39376,19 @@ class GridSelectionPlugin extends UIPlugin {
39335
39376
  }
39336
39377
  }
39337
39378
  getStatisticFnResults() {
39338
- // get deduplicated cells in zones
39339
- const cells = new Set(this.gridSelection.zones
39340
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39341
- .flat()
39342
- .filter((cell) => cell.type !== CellValueType.empty));
39379
+ const sheetId = this.getters.getActiveSheetId();
39380
+ const cells = new Set();
39381
+ for (const zone of this.gridSelection.zones) {
39382
+ for (const { col, row } of positions(zone)) {
39383
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39384
+ continue; // Skip hidden cells
39385
+ }
39386
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39387
+ if (evaluatedCell.type !== CellValueType.empty) {
39388
+ cells.add(evaluatedCell);
39389
+ }
39390
+ }
39391
+ }
39343
39392
  let cellsTypes = new Set();
39344
39393
  let cellsValues = [];
39345
39394
  for (let cell of cells) {
@@ -45453,6 +45502,6 @@ function addFunction(functionName, functionDescription) {
45453
45502
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, 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, setTranslationMethod, tokenize };
45454
45503
 
45455
45504
 
45456
- __info__.version = '16.2.18';
45457
- __info__.date = '2023-10-10T07:29:40.321Z';
45458
- __info__.hash = '451fa09';
45505
+ __info__.version = '16.2.20';
45506
+ __info__.date = '2023-10-25T10:00:14.966Z';
45507
+ __info__.hash = '25a402d';
@@ -4304,6 +4304,9 @@
4304
4304
  CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4305
4305
  })(exports.CommandResult || (exports.CommandResult = {}));
4306
4306
 
4307
+ function isMatrix(x) {
4308
+ return Array.isArray(x) && Array.isArray(x[0]);
4309
+ }
4307
4310
  var DIRECTION;
4308
4311
  (function (DIRECTION) {
4309
4312
  DIRECTION["UP"] = "up";
@@ -15170,6 +15173,36 @@
15170
15173
  isExported: true,
15171
15174
  };
15172
15175
  // -----------------------------------------------------------------------------
15176
+ // INDEX
15177
+ // -----------------------------------------------------------------------------
15178
+ const INDEX = {
15179
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15180
+ args: [
15181
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15182
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15183
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15184
+ ],
15185
+ returns: ["ANY"],
15186
+ computeFormat: (reference, row, column) => {
15187
+ var _a;
15188
+ const _row = toNumber(row.value);
15189
+ const _column = toNumber(column.value);
15190
+ return (_a = reference[_column - 1][_row - 1]) === null || _a === void 0 ? void 0 : _a.format;
15191
+ },
15192
+ compute: function (reference, row, column) {
15193
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15194
+ const _row = toNumber(row);
15195
+ const _column = toNumber(column);
15196
+ assert(() => _column >= 0 &&
15197
+ _column - 1 < _reference.length &&
15198
+ _row >= 0 &&
15199
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15200
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15201
+ return _reference[_column - 1][_row - 1];
15202
+ },
15203
+ isExported: true,
15204
+ };
15205
+ // -----------------------------------------------------------------------------
15173
15206
  // LOOKUP
15174
15207
  // -----------------------------------------------------------------------------
15175
15208
  const LOOKUP = {
@@ -15364,6 +15397,7 @@
15364
15397
  COLUMN: COLUMN,
15365
15398
  COLUMNS: COLUMNS,
15366
15399
  HLOOKUP: HLOOKUP,
15400
+ INDEX: INDEX,
15367
15401
  LOOKUP: LOOKUP,
15368
15402
  MATCH: MATCH,
15369
15403
  ROW: ROW,
@@ -19361,7 +19395,7 @@
19361
19395
  left: `${x - 1}px`,
19362
19396
  border: `1px solid ${color}`,
19363
19397
  "background-color": color,
19364
- opacity: this.props.active ? "opacity:1 !important" : undefined,
19398
+ opacity: this.props.active ? "1 !important" : undefined,
19365
19399
  });
19366
19400
  }
19367
19401
  }
@@ -25523,12 +25557,15 @@
25523
25557
  };
25524
25558
  }
25525
25559
  function xmlEscape(str) {
25526
- return String(str)
25560
+ return (String(str)
25527
25561
  .replace(/\&/g, "&amp;")
25528
25562
  .replace(/\</g, "&lt;")
25529
25563
  .replace(/\>/g, "&gt;")
25530
25564
  .replace(/\"/g, "&quot;")
25531
- .replace(/\'/g, "&apos;");
25565
+ .replace(/\'/g, "&apos;")
25566
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
25567
+ // They are not valid at all in XML 1.0 (even escaped)
25568
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
25532
25569
  }
25533
25570
  function formatAttributes(attrs) {
25534
25571
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -32591,6 +32628,10 @@
32591
32628
  }
32592
32629
  currentRanges = currentRanges.concat(toAdd);
32593
32630
  const newRangesXC = recomputeZones(currentRanges, toRemove);
32631
+ if (newRangesXC.length === 0) {
32632
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
32633
+ return;
32634
+ }
32594
32635
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
32595
32636
  cf: {
32596
32637
  id: cf.id,
@@ -39336,11 +39377,19 @@
39336
39377
  }
39337
39378
  }
39338
39379
  getStatisticFnResults() {
39339
- // get deduplicated cells in zones
39340
- const cells = new Set(this.gridSelection.zones
39341
- .map((zone) => this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(), zone))
39342
- .flat()
39343
- .filter((cell) => cell.type !== CellValueType.empty));
39380
+ const sheetId = this.getters.getActiveSheetId();
39381
+ const cells = new Set();
39382
+ for (const zone of this.gridSelection.zones) {
39383
+ for (const { col, row } of positions(zone)) {
39384
+ if (this.getters.isRowHidden(sheetId, row) || this.getters.isColHidden(sheetId, col)) {
39385
+ continue; // Skip hidden cells
39386
+ }
39387
+ const evaluatedCell = this.getters.getEvaluatedCell({ sheetId, col, row });
39388
+ if (evaluatedCell.type !== CellValueType.empty) {
39389
+ cells.add(evaluatedCell);
39390
+ }
39391
+ }
39392
+ }
39344
39393
  let cellsTypes = new Set();
39345
39394
  let cellsValues = [];
39346
39395
  for (let cell of cells) {
@@ -45484,9 +45533,9 @@
45484
45533
  Object.defineProperty(exports, '__esModule', { value: true });
45485
45534
 
45486
45535
 
45487
- __info__.version = '16.2.18';
45488
- __info__.date = '2023-10-10T07:29:40.321Z';
45489
- __info__.hash = '451fa09';
45536
+ __info__.version = '16.2.20';
45537
+ __info__.date = '2023-10-25T10:00:14.966Z';
45538
+ __info__.hash = '25a402d';
45490
45539
 
45491
45540
 
45492
45541
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);