@odoo/o-spreadsheet 17.0.32 → 17.0.33

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.32
6
- * @date 2024-07-24T10:26:05.203Z
7
- * @hash 679a547
5
+ * @version 17.0.33
6
+ * @date 2024-08-02T08:18:55.061Z
7
+ * @hash 4ad4049
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillUnmount, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -592,7 +592,7 @@ function debounce(func, wait, immediate) {
592
592
  let timeout;
593
593
  return function () {
594
594
  const context = this;
595
- const args = arguments;
595
+ const args = Array.from(arguments);
596
596
  function later() {
597
597
  timeout = null;
598
598
  if (!immediate) {
@@ -795,7 +795,7 @@ function isNumberBetween(value, min, max) {
795
795
  */
796
796
  function largeMax(array) {
797
797
  let len = array.length;
798
- if (len < 100000)
798
+ if (len < 100_000)
799
799
  return Math.max(...array);
800
800
  let max = -Infinity;
801
801
  while (len--) {
@@ -809,7 +809,7 @@ function largeMax(array) {
809
809
  */
810
810
  function largeMin(array) {
811
811
  let len = array.length;
812
- if (len < 100000)
812
+ if (len < 100_000)
813
813
  return Math.min(...array);
814
814
  let min = +Infinity;
815
815
  while (len--) {
@@ -2564,13 +2564,16 @@ function operandToRegExp(operand) {
2564
2564
  }
2565
2565
  return new RegExp("^" + exp + "$", "i");
2566
2566
  }
2567
- function evaluatePredicate(value = "", criterion) {
2567
+ function evaluatePredicate(value = "", criterion, locale) {
2568
2568
  const { operator, operand } = criterion;
2569
2569
  if (operand === undefined || value === null || operand === null) {
2570
2570
  return false;
2571
2571
  }
2572
2572
  if (typeof operand === "number" && operator === "=") {
2573
- return toString(value) === toString(operand);
2573
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2574
+ return toNumber(value, locale) === operand;
2575
+ }
2576
+ return value === operand;
2574
2577
  }
2575
2578
  if (operator === "<>" || operator === "=") {
2576
2579
  let result;
@@ -2649,7 +2652,7 @@ function visitMatchingRanges(args, cb, locale, isQuery = false) {
2649
2652
  for (let k = 0; k < countArg - 1; k += 2) {
2650
2653
  const criteriaValue = args[k][i][j];
2651
2654
  const criterion = predicates[k / 2];
2652
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2655
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2653
2656
  if (!validatedPredicates) {
2654
2657
  break;
2655
2658
  }
@@ -5898,7 +5901,7 @@ function textCell(value, localeFormat) {
5898
5901
  function numberCell(value, localeFormat) {
5899
5902
  return {
5900
5903
  type: CellValueType.number,
5901
- value: value || 0,
5904
+ value: value || 0, // necessary to avoid "-0" and NaN values,
5902
5905
  format: localeFormat.format,
5903
5906
  isAutoSummable: true,
5904
5907
  defaultAlign: "right",
@@ -8431,8 +8434,8 @@ function truncateLabel(label) {
8431
8434
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
8432
8435
  const options = {
8433
8436
  // https://www.chartjs.org/docs/latest/general/responsive.html
8434
- responsive: true,
8435
- maintainAspectRatio: false,
8437
+ responsive: true, // will resize when its container is resized
8438
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
8436
8439
  layout: {
8437
8440
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
8438
8441
  },
@@ -8741,7 +8744,7 @@ function getBarConfiguration(chart, labels, localeFormat) {
8741
8744
  },
8742
8745
  y: {
8743
8746
  position: chart.verticalAxisPosition,
8744
- beginAtZero: true,
8747
+ beginAtZero: true, // the origin of the y axis is always zero
8745
8748
  ticks: {
8746
8749
  color: fontColor,
8747
8750
  callback: (value) => {
@@ -9395,7 +9398,7 @@ function getLineConfiguration(chart, labels, options) {
9395
9398
  },
9396
9399
  y: {
9397
9400
  position: chart.verticalAxisPosition,
9398
- beginAtZero: true,
9401
+ beginAtZero: true, // the origin of the y axis is always zero
9399
9402
  ticks: {
9400
9403
  color: fontColor,
9401
9404
  callback: (value) => {
@@ -9483,7 +9486,7 @@ function createLineChartRuntime(chart, getters) {
9483
9486
  const dataset = {
9484
9487
  label,
9485
9488
  data,
9486
- tension: 0,
9489
+ tension: 0, // 0 -> render straight lines, which is much faster
9487
9490
  borderColor: color,
9488
9491
  backgroundColor,
9489
9492
  pointBackgroundColor: color,
@@ -9594,7 +9597,7 @@ class PieChart extends AbstractChart {
9594
9597
  ...this.getDefinition(),
9595
9598
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
9596
9599
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
9597
- verticalAxisPosition: "left",
9600
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
9598
9601
  dataSets,
9599
9602
  labelRange,
9600
9603
  };
@@ -26698,7 +26701,9 @@ class Composer extends Component {
26698
26701
  argToFocus: 0,
26699
26702
  });
26700
26703
  compositionActive = false;
26704
+ spreadsheetRect = useSpreadsheetRect();
26701
26705
  get assistantStyle() {
26706
+ const composerRect = this.composerRef.el.getBoundingClientRect();
26702
26707
  const assistantStyle = {};
26703
26708
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
26704
26709
  if (this.autoCompleteState.type === "function") {
@@ -26721,6 +26726,10 @@ class Composer extends Component {
26721
26726
  assistantStyle.right = `0px`;
26722
26727
  }
26723
26728
  }
26729
+ if (this.props.focus === "contentFocus" &&
26730
+ composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
26731
+ assistantStyle.right = "0px";
26732
+ }
26724
26733
  return cssPropertiesToCss(assistantStyle);
26725
26734
  }
26726
26735
  // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent
@@ -29579,7 +29588,7 @@ class VerticalScrollBar extends Component {
29579
29588
  onScroll(offset) {
29580
29589
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
29581
29590
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
29582
- offsetX: scrollX,
29591
+ offsetX: scrollX, // offsetX is the same
29583
29592
  offsetY: offset,
29584
29593
  });
29585
29594
  }
@@ -29790,8 +29799,8 @@ class Grid extends Component {
29790
29799
  "CTRL+SHIFT+L": () => this.setHorizontalAlign("left"),
29791
29800
  "CTRL+SHIFT+R": () => this.setHorizontalAlign("right"),
29792
29801
  "CTRL+SHIFT+V": () => PASTE_VALUE_ACTION(this.env),
29793
- "CTRL+SHIFT+<": () => this.clearFormatting(),
29794
- "CTRL+<": () => this.clearFormatting(),
29802
+ "CTRL+SHIFT+<": () => this.clearFormatting(), // for qwerty
29803
+ "CTRL+<": () => this.clearFormatting(), // for azerty
29795
29804
  "CTRL+SHIFT+ ": () => {
29796
29805
  this.env.model.selection.selectAll();
29797
29806
  },
@@ -30605,10 +30614,10 @@ function convertCFCellIsOperator(xlsxCfOperator) {
30605
30614
  const CF_TYPE_CONVERSION_MAP = {
30606
30615
  aboveAverage: undefined,
30607
30616
  expression: undefined,
30608
- cellIs: undefined,
30609
- colorScale: undefined,
30617
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
30618
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
30610
30619
  dataBar: undefined,
30611
- iconSet: undefined,
30620
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
30612
30621
  top10: undefined,
30613
30622
  uniqueValues: undefined,
30614
30623
  duplicateValues: undefined,
@@ -30843,7 +30852,7 @@ const XLSX_INDEXED_COLORS = {
30843
30852
  61: "993366",
30844
30853
  62: "333399",
30845
30854
  63: "333333",
30846
- 64: "000000",
30855
+ 64: "000000", // system foreground
30847
30856
  65: "FFFFFF", // system background
30848
30857
  };
30849
30858
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34484,12 +34493,13 @@ class BordersPlugin extends CorePlugin {
34484
34493
  this.clearBorders(cmd.sheetId, cmd.target);
34485
34494
  break;
34486
34495
  case "REMOVE_COLUMNS_ROWS":
34487
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
34496
+ const elements = [...cmd.elements].sort((a, b) => b - a);
34497
+ for (const group of groupConsecutive(elements)) {
34488
34498
  if (cmd.dimension === "COL") {
34489
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34499
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34490
34500
  }
34491
34501
  else {
34492
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34502
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34493
34503
  }
34494
34504
  }
34495
34505
  break;
@@ -39550,12 +39560,7 @@ class SheetPlugin extends CorePlugin {
39550
39560
  });
39551
39561
  }
39552
39562
  if (colIndex > deletedColumn) {
39553
- this.dispatch("UPDATE_CELL_POSITION", {
39554
- sheetId: sheet.id,
39555
- cellId: cellId,
39556
- col: colIndex - 1,
39557
- row: rowIndex,
39558
- });
39563
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
39559
39564
  }
39560
39565
  }
39561
39566
  }
@@ -39565,7 +39570,7 @@ class SheetPlugin extends CorePlugin {
39565
39570
  * Move the cells after a column or rows insertion
39566
39571
  */
39567
39572
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
39568
- const commands = [];
39573
+ const updates = [];
39569
39574
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
39570
39575
  const row = sheet.rows[rowIndex];
39571
39576
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -39574,20 +39579,20 @@ class SheetPlugin extends CorePlugin {
39574
39579
  const cellId = row.cells[i];
39575
39580
  if (cellId) {
39576
39581
  if (dimension === "rows" || colIndex >= addedElement) {
39577
- commands.push({
39578
- type: "UPDATE_CELL_POSITION",
39582
+ updates.push({
39579
39583
  sheetId: sheet.id,
39580
39584
  cellId: cellId,
39581
39585
  col: colIndex + (dimension === "columns" ? quantity : 0),
39582
39586
  row: rowIndex + (dimension === "rows" ? quantity : 0),
39587
+ type: "UPDATE_CELL_POSITION",
39583
39588
  });
39584
39589
  }
39585
39590
  }
39586
39591
  }
39587
39592
  }
39588
39593
  }
39589
- for (let cmd of commands.reverse()) {
39590
- this.dispatch(cmd.type, cmd);
39594
+ for (let update of updates.reverse()) {
39595
+ this.updateCellPosition(update);
39591
39596
  }
39592
39597
  }
39593
39598
  /**
@@ -39620,12 +39625,7 @@ class SheetPlugin extends CorePlugin {
39620
39625
  const colIndex = Number(i);
39621
39626
  const cellId = row.cells[i];
39622
39627
  if (cellId) {
39623
- this.dispatch("UPDATE_CELL_POSITION", {
39624
- sheetId: sheet.id,
39625
- cellId: cellId,
39626
- col: colIndex,
39627
- row: rowIndex - numberRows,
39628
- });
39628
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
39629
39629
  }
39630
39630
  }
39631
39631
  }
@@ -42238,17 +42238,17 @@ function isBadExpression(tokens) {
42238
42238
  */
42239
42239
  function sortWithClusters(colorsToSort) {
42240
42240
  const clusters = [
42241
- { leadColor: rgba(255, 0, 0), colors: [] },
42242
- { leadColor: rgba(255, 128, 0), colors: [] },
42243
- { leadColor: rgba(128, 128, 0), colors: [] },
42244
- { leadColor: rgba(128, 255, 0), colors: [] },
42245
- { leadColor: rgba(0, 255, 0), colors: [] },
42246
- { leadColor: rgba(0, 255, 128), colors: [] },
42247
- { leadColor: rgba(0, 255, 255), colors: [] },
42248
- { leadColor: rgba(0, 127, 255), colors: [] },
42249
- { leadColor: rgba(0, 0, 255), colors: [] },
42250
- { leadColor: rgba(127, 0, 255), colors: [] },
42251
- { leadColor: rgba(128, 0, 128), colors: [] },
42241
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
42242
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
42243
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
42244
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
42245
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
42246
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
42247
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
42248
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
42249
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
42250
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
42251
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
42252
42252
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42253
42253
  ];
42254
42254
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -52158,7 +52158,7 @@ class BottomBar extends Component {
52158
52158
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52159
52159
  .map((rect) => ({
52160
52160
  x: rect.x,
52161
- width: rect.width - 1,
52161
+ width: rect.width - 1, // -1 to compensate negative margin
52162
52162
  y: rect.y,
52163
52163
  height: rect.height,
52164
52164
  }));
@@ -52383,7 +52383,7 @@ class RowGroup extends AbstractHeaderGroup {
52383
52383
  }
52384
52384
  return cssPropertiesToCss({
52385
52385
  top: `${groupBox.headerRect.height / 2}px`,
52386
- left: `calc(50% - 1px)`,
52386
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52387
52387
  width: `30%`,
52388
52388
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52389
52389
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52435,7 +52435,7 @@ class ColGroup extends AbstractHeaderGroup {
52435
52435
  return "";
52436
52436
  }
52437
52437
  return cssPropertiesToCss({
52438
- top: `calc(50% - 1px)`,
52438
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52439
52439
  left: `${groupBox.headerRect.width / 2}px`,
52440
52440
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52441
52441
  height: `30%`,
@@ -53836,7 +53836,7 @@ class Spreadsheet extends Component {
53836
53836
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
53837
53837
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
53838
53838
  return cssPropertiesToCss({
53839
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
53839
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
53840
53840
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
53841
53841
  });
53842
53842
  }
@@ -55339,7 +55339,7 @@ class SelectionStreamProcessorImpl {
55339
55339
  }
55340
55340
 
55341
55341
  class StateObserver {
55342
- changes = [];
55342
+ changes;
55343
55343
  commands = [];
55344
55344
  /**
55345
55345
  * Record the changes which could happen in the given callback, save them in a
@@ -55371,7 +55371,7 @@ class StateObserver {
55371
55371
  if (value[key] === val) {
55372
55372
  return;
55373
55373
  }
55374
- this.changes.push({
55374
+ this.changes?.push({
55375
55375
  path: args,
55376
55376
  before: value[key],
55377
55377
  after: val,
@@ -56502,7 +56502,7 @@ function addTableColumns(table, sheetData) {
56502
56502
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56503
56503
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56504
56504
  const colAttributes = [
56505
- ["id", i + 1],
56505
+ ["id", i + 1], // id cannot be 0
56506
56506
  ["name", colName],
56507
56507
  ];
56508
56508
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57549,6 +57549,6 @@ const constants = {
57549
57549
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, 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 };
57550
57550
 
57551
57551
 
57552
- __info__.version = "17.0.32";
57553
- __info__.date = "2024-07-24T10:26:05.203Z";
57554
- __info__.hash = "679a547";
57552
+ __info__.version = "17.0.33";
57553
+ __info__.date = "2024-08-02T08:18:55.061Z";
57554
+ __info__.hash = "4ad4049";