@odoo/o-spreadsheet 18.0.6 → 18.0.7

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 18.0.6
6
- * @date 2024-11-28T09:05:39.780Z
7
- * @hash 6e043e4
5
+ * @version 18.0.7
6
+ * @date 2024-12-05T10:41:39.380Z
7
+ * @hash a2652c5
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -333,8 +333,8 @@
333
333
  const DEBOUNCE_TIME = 200;
334
334
  const MESSAGE_VERSION = 1;
335
335
  // Sheets
336
- const FORBIDDEN_SHEET_CHARS = ["'", "*", "?", "/", "\\", "[", "]"];
337
- const FORBIDDEN_IN_EXCEL_REGEX = /'|\*|\?|\/|\\|\[|\]/;
336
+ const FORBIDDEN_SHEETNAME_CHARS = ["'", "*", "?", "/", "\\", "[", "]"];
337
+ const FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX = /'|\*|\?|\/|\\|\[|\]/;
338
338
  // Cells
339
339
  const FORMULA_REF_IDENTIFIER = "|";
340
340
  // Components
@@ -387,6 +387,7 @@
387
387
  //------------------------------------------------------------------------------
388
388
  // Miscellaneous
389
389
  //------------------------------------------------------------------------------
390
+ const sanitizeSheetNameRegex = new RegExp(FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX, "g");
390
391
  /**
391
392
  * Remove quotes from a quoted string
392
393
  * ```js
@@ -482,6 +483,10 @@
482
483
  }
483
484
  return symbolName;
484
485
  }
486
+ /** Replace the excel-excluded characters of a sheetName */
487
+ function sanitizeSheetName(sheetName, replacementChar = " ") {
488
+ return sheetName.replace(sanitizeSheetNameRegex, replacementChar);
489
+ }
485
490
  function clip(val, min, max) {
486
491
  return val < min ? min : val > max ? max : val;
487
492
  }
@@ -9415,34 +9420,42 @@ stores.inject(MyMetaStore, storeInstance);
9415
9420
  const labelRange = labelMax - labelMin;
9416
9421
  const normalizedLabels = labels.map((v) => (v - labelMin) / labelRange);
9417
9422
  const normalizedNewLabels = newLabels.map((v) => (v - labelMin) / labelRange);
9418
- switch (config.type) {
9419
- case "polynomial": {
9420
- const order = config.order ?? 2;
9421
- if (order === 1) {
9422
- return predictLinearValues([values], [normalizedLabels], [normalizedNewLabels], true)[0];
9423
- }
9424
- const coeffs = polynomialRegression(values, normalizedLabels, order, true).flat();
9425
- return normalizedNewLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9426
- }
9427
- case "exponential": {
9428
- const positiveLogValues = [];
9429
- const filteredLabels = [];
9430
- for (let i = 0; i < values.length; i++) {
9431
- if (values[i] > 0) {
9432
- positiveLogValues.push(Math.log(values[i]));
9433
- filteredLabels.push(normalizedLabels[i]);
9423
+ try {
9424
+ switch (config.type) {
9425
+ case "polynomial": {
9426
+ const order = config.order;
9427
+ if (!order) {
9428
+ return Array.from({ length: newLabels.length }, () => NaN);
9429
+ }
9430
+ if (order === 1) {
9431
+ return predictLinearValues([values], [normalizedLabels], [normalizedNewLabels], true)[0];
9432
+ }
9433
+ const coeffs = polynomialRegression(values, normalizedLabels, order, true).flat();
9434
+ return normalizedNewLabels.map((v) => evaluatePolynomial(coeffs, v, order));
9435
+ }
9436
+ case "exponential": {
9437
+ const positiveLogValues = [];
9438
+ const filteredLabels = [];
9439
+ for (let i = 0; i < values.length; i++) {
9440
+ if (values[i] > 0) {
9441
+ positiveLogValues.push(Math.log(values[i]));
9442
+ filteredLabels.push(normalizedLabels[i]);
9443
+ }
9434
9444
  }
9445
+ if (!filteredLabels.length) {
9446
+ return Array.from({ length: newLabels.length }, () => NaN);
9447
+ }
9448
+ return expM(predictLinearValues([positiveLogValues], [filteredLabels], [normalizedNewLabels], true))[0];
9435
9449
  }
9436
- if (!filteredLabels.length) {
9437
- return [];
9450
+ case "logarithmic": {
9451
+ return predictLinearValues([values], logM([normalizedLabels]), logM([normalizedNewLabels]), true)[0];
9438
9452
  }
9439
- return expM(predictLinearValues([positiveLogValues], [filteredLabels], [normalizedNewLabels], true))[0];
9440
- }
9441
- case "logarithmic": {
9442
- return predictLinearValues([values], logM([normalizedLabels]), logM([normalizedNewLabels]), true)[0];
9453
+ default:
9454
+ return [];
9443
9455
  }
9444
- default:
9445
- return [];
9456
+ }
9457
+ catch (e) {
9458
+ return Array.from({ length: newLabels.length }, () => NaN);
9446
9459
  }
9447
9460
  }
9448
9461
  function formatTickValue(localeFormat) {
@@ -27241,13 +27254,12 @@ stores.inject(MyMetaStore, storeInstance);
27241
27254
  versionFrom: "7",
27242
27255
  migrate(data) {
27243
27256
  const namesTaken = [];
27244
- const globalForbiddenInExcel = new RegExp(FORBIDDEN_IN_EXCEL_REGEX, "g");
27245
27257
  for (let sheet of data.sheets || []) {
27246
27258
  if (!sheet.name) {
27247
27259
  continue;
27248
27260
  }
27249
27261
  const oldName = sheet.name;
27250
- const escapedName = oldName.replace(globalForbiddenInExcel, "_");
27262
+ const escapedName = sanitizeSheetName(oldName, "_");
27251
27263
  let i = 1;
27252
27264
  let newName = escapedName;
27253
27265
  while (namesTaken.includes(newName)) {
@@ -37461,7 +37473,7 @@ stores.inject(MyMetaStore, storeInstance);
37461
37473
  case "polynomial":
37462
37474
  config = {
37463
37475
  type: "polynomial",
37464
- order: type === "linear" ? 1 : 2,
37476
+ order: type === "linear" ? 1 : this.getMaxPolynomialDegree(),
37465
37477
  };
37466
37478
  break;
37467
37479
  case "exponential":
@@ -38537,20 +38549,8 @@ stores.inject(MyMetaStore, storeInstance);
38537
38549
  replaceSelectedRange(zone) {
38538
38550
  const ref = this.getZoneReference(zone);
38539
38551
  const currentToken = this.tokenAtCursor;
38540
- let replaceStart = this.selectionStart;
38541
- if (currentToken?.type === "REFERENCE") {
38542
- replaceStart = currentToken.start;
38543
- }
38544
- else if (currentToken?.type === "RIGHT_PAREN") {
38545
- // match left parenthesis
38546
- const leftParenthesisIndex = this.currentTokens.findIndex((token) => token.type === "LEFT_PAREN" && token.parenIndex === currentToken.parenIndex);
38547
- const functionToken = this.currentTokens[leftParenthesisIndex - 1];
38548
- if (functionToken === undefined) {
38549
- return;
38550
- }
38551
- replaceStart = functionToken.start;
38552
- }
38553
- this.replaceText(ref, replaceStart, this.selectionEnd);
38552
+ const start = currentToken?.type === "REFERENCE" ? currentToken.start : this.selectionStart;
38553
+ this.replaceText(ref, start, this.selectionEnd);
38554
38554
  }
38555
38555
  /**
38556
38556
  * Replace the reference of the old zone by the new one.
@@ -38583,17 +38583,6 @@ stores.inject(MyMetaStore, storeInstance);
38583
38583
  getZoneReference(zone) {
38584
38584
  const inputSheetId = this.sheetId;
38585
38585
  const sheetId = this.getters.getActiveSheetId();
38586
- if (zone.top === zone.bottom && zone.left === zone.right) {
38587
- const position = { sheetId, col: zone.left, row: zone.top };
38588
- const pivotId = this.getters.getPivotIdFromPosition(position);
38589
- const pivotCell = this.getters.getPivotCellFromPosition(position);
38590
- const cell = this.getters.getCell(position);
38591
- if (pivotId && pivotCell.type !== "EMPTY" && !cell?.isFormula) {
38592
- const formulaPivotId = this.getters.getPivotFormulaId(pivotId);
38593
- const formula = createPivotFormula(formulaPivotId, pivotCell);
38594
- return localizeFormula(formula, this.getters.getLocale()).slice(1); // strip leading =
38595
- }
38596
- }
38597
38586
  const range = this.getters.getRangeFromZone(sheetId, zone);
38598
38587
  return this.getters.getSelectionRangeString(range, inputSheetId);
38599
38588
  }
@@ -38664,35 +38653,19 @@ stores.inject(MyMetaStore, storeInstance);
38664
38653
  const colorIndex = this.colorIndexByRange[rangeString];
38665
38654
  return colors$1[colorIndex % colors$1.length];
38666
38655
  };
38667
- const highlights = [];
38668
- for (const range of this.getReferencedRanges()) {
38656
+ return this.getReferencedRanges().map((range) => {
38669
38657
  const rangeString = this.getters.getRangeString(range, editionSheetId);
38670
38658
  const { numberOfRows, numberOfCols } = zoneToDimension(range.zone);
38671
38659
  const zone = numberOfRows * numberOfCols === 1
38672
38660
  ? this.getters.expandZone(range.sheetId, range.zone)
38673
38661
  : range.zone;
38674
- highlights.push({
38662
+ return {
38675
38663
  zone,
38676
38664
  color: rangeColor(rangeString),
38677
38665
  sheetId: range.sheetId,
38678
38666
  interactive: true,
38679
- });
38680
- }
38681
- const activeSheetId = this.getters.getActiveSheetId();
38682
- const selectionZone = this.model.selection.getAnchor().zone;
38683
- const isSelectionHightlighted = highlights.find((highlight) => highlight.sheetId === activeSheetId && isEqual(highlight.zone, selectionZone));
38684
- if (this.editionMode === "selecting" && !isSelectionHightlighted) {
38685
- highlights.push({
38686
- zone: selectionZone,
38687
- color: "#445566",
38688
- sheetId: activeSheetId,
38689
- dashed: true,
38690
- interactive: false,
38691
- noFill: true,
38692
- thinLine: true,
38693
- });
38694
- }
38695
- return highlights;
38667
+ };
38668
+ });
38696
38669
  }
38697
38670
  /**
38698
38671
  * Return ranges currently referenced in the composer
@@ -54278,7 +54251,7 @@ stores.inject(MyMetaStore, storeInstance);
54278
54251
  if (orderedSheetIds.find((id) => sheets[id]?.name.toLowerCase() === name && id !== cmd.sheetId)) {
54279
54252
  return "DuplicatedSheetName" /* CommandResult.DuplicatedSheetName */;
54280
54253
  }
54281
- if (FORBIDDEN_IN_EXCEL_REGEX.test(name)) {
54254
+ if (FORBIDDEN_SHEETNAME_CHARS_IN_EXCEL_REGEX.test(name)) {
54282
54255
  return "ForbiddenCharactersInSheetName" /* CommandResult.ForbiddenCharactersInSheetName */;
54283
54256
  }
54284
54257
  return "Success" /* CommandResult.Success */;
@@ -59681,11 +59654,13 @@ stores.inject(MyMetaStore, storeInstance);
59681
59654
  return EMPTY_PIVOT_CELL;
59682
59655
  }
59683
59656
  if (functionName === "PIVOT") {
59684
- const includeTotal = args[2] === false ? false : undefined;
59685
- const includeColumnHeaders = args[3] === false ? false : undefined;
59657
+ const includeTotal = toScalar(args[2]);
59658
+ const shouldIncludeTotal = includeTotal === undefined ? true : toBoolean(includeTotal);
59659
+ const includeColumnHeaders = toScalar(args[3]);
59660
+ const shouldIncludeColumnHeaders = includeColumnHeaders === undefined ? true : toBoolean(includeColumnHeaders);
59686
59661
  const pivotCells = pivot
59687
59662
  .getTableStructure()
59688
- .getPivotCells(includeTotal, includeColumnHeaders);
59663
+ .getPivotCells(shouldIncludeTotal, shouldIncludeColumnHeaders);
59689
59664
  const pivotCol = position.col - mainPosition.col;
59690
59665
  const pivotRow = position.row - mainPosition.row;
59691
59666
  return pivotCells[pivotCol][pivotRow];
@@ -61841,7 +61816,7 @@ stores.inject(MyMetaStore, storeInstance);
61841
61816
  getPivotDuplicateSheetName(pivotName) {
61842
61817
  let i = 1;
61843
61818
  const names = this.getters.getSheetIds().map((id) => this.getters.getSheetName(id));
61844
- const sanitizedName = pivotName.replace(new RegExp(FORBIDDEN_IN_EXCEL_REGEX, "g"), " ");
61819
+ const sanitizedName = sanitizeSheetName(pivotName);
61845
61820
  let name = sanitizedName;
61846
61821
  while (names.includes(name)) {
61847
61822
  name = `${sanitizedName} (${i})`;
@@ -65921,7 +65896,7 @@ stores.inject(MyMetaStore, storeInstance);
65921
65896
  env.raiseError(_t("A sheet with the name %s already exists. Please select another name.", name), errorCallback);
65922
65897
  }
65923
65898
  else if (result.reasons.includes("ForbiddenCharactersInSheetName" /* CommandResult.ForbiddenCharactersInSheetName */)) {
65924
- env.raiseError(_t("Some used characters are not allowed in a sheet name (Forbidden characters are %s).", FORBIDDEN_SHEET_CHARS.join(" ")), errorCallback);
65899
+ env.raiseError(_t("Some used characters are not allowed in a sheet name (Forbidden characters are %s).", FORBIDDEN_SHEETNAME_CHARS.join(" ")), errorCallback);
65925
65900
  }
65926
65901
  }
65927
65902
 
@@ -67151,7 +67126,7 @@ stores.inject(MyMetaStore, storeInstance);
67151
67126
  setup() {
67152
67127
  owl.onWillUpdateProps((nextProps) => {
67153
67128
  if (nextProps.action !== this.props.action) {
67154
- this.actionButton = createAction(this.props.action);
67129
+ this.actionButton = createAction(nextProps.action);
67155
67130
  }
67156
67131
  });
67157
67132
  }
@@ -69330,9 +69305,6 @@ stores.inject(MyMetaStore, storeInstance);
69330
69305
  getBackToDefault() {
69331
69306
  this.stream.getBackToDefault();
69332
69307
  }
69333
- getAnchor() {
69334
- return this.anchor;
69335
- }
69336
69308
  modifyAnchor(anchor, mode, options) {
69337
69309
  const sheetId = this.getters.getActiveSheetId();
69338
69310
  anchor = {
@@ -72420,6 +72392,7 @@ stores.inject(MyMetaStore, storeInstance);
72420
72392
  areDomainArgsFieldsValid,
72421
72393
  splitReference,
72422
72394
  formatTickValue,
72395
+ sanitizeSheetName,
72423
72396
  };
72424
72397
  const links = {
72425
72398
  isMarkdownLink,
@@ -72555,9 +72528,9 @@ stores.inject(MyMetaStore, storeInstance);
72555
72528
  exports.tokenize = tokenize;
72556
72529
 
72557
72530
 
72558
- __info__.version = "18.0.6";
72559
- __info__.date = "2024-11-28T09:05:39.780Z";
72560
- __info__.hash = "6e043e4";
72531
+ __info__.version = "18.0.7";
72532
+ __info__.date = "2024-12-05T10:41:39.380Z";
72533
+ __info__.hash = "a2652c5";
72561
72534
 
72562
72535
 
72563
72536
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);