@odoo/o-spreadsheet 17.1.25 → 17.1.26

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.1.25
6
- * @date 2024-07-24T10:26:01.576Z
7
- * @hash 0edff47
5
+ * @version 17.1.26
6
+ * @date 2024-08-02T08:23:08.499Z
7
+ * @hash 4ba7e55
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, onWillUnmount, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -479,7 +479,7 @@ function debounce(func, wait, immediate) {
479
479
  let timeout;
480
480
  return function () {
481
481
  const context = this;
482
- const args = arguments;
482
+ const args = Array.from(arguments);
483
483
  function later() {
484
484
  timeout = null;
485
485
  if (!immediate) {
@@ -682,7 +682,7 @@ function isNumberBetween(value, min, max) {
682
682
  */
683
683
  function largeMax(array) {
684
684
  let len = array.length;
685
- if (len < 100000)
685
+ if (len < 100_000)
686
686
  return Math.max(...array);
687
687
  let max = -Infinity;
688
688
  while (len--) {
@@ -696,7 +696,7 @@ function largeMax(array) {
696
696
  */
697
697
  function largeMin(array) {
698
698
  let len = array.length;
699
- if (len < 100000)
699
+ if (len < 100_000)
700
700
  return Math.min(...array);
701
701
  let min = +Infinity;
702
702
  while (len--) {
@@ -2613,13 +2613,16 @@ function operandToRegExp(operand) {
2613
2613
  }
2614
2614
  return new RegExp("^" + exp + "$", "i");
2615
2615
  }
2616
- function evaluatePredicate(value = "", criterion) {
2616
+ function evaluatePredicate(value = "", criterion, locale) {
2617
2617
  const { operator, operand } = criterion;
2618
2618
  if (operand === undefined || value === null || operand === null) {
2619
2619
  return false;
2620
2620
  }
2621
2621
  if (typeof operand === "number" && operator === "=") {
2622
- return value.toString() === operand.toString();
2622
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2623
+ return toNumber(value, locale) === operand;
2624
+ }
2625
+ return value === operand;
2623
2626
  }
2624
2627
  if (operator === "<>" || operator === "=") {
2625
2628
  let result;
@@ -2697,7 +2700,7 @@ function visitMatchingRanges(args, cb, locale, isQuery = false) {
2697
2700
  for (let k = 0; k < countArg - 1; k += 2) {
2698
2701
  const criteriaValue = toMatrix(args[k])[i][j].value;
2699
2702
  const criterion = predicates[k / 2];
2700
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2703
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2701
2704
  if (!validatedPredicates) {
2702
2705
  break;
2703
2706
  }
@@ -5979,7 +5982,7 @@ function textCell(value, localeFormat) {
5979
5982
  function numberCell(value, localeFormat) {
5980
5983
  return {
5981
5984
  type: CellValueType.number,
5982
- value: value || 0,
5985
+ value: value || 0, // necessary to avoid "-0" and NaN values,
5983
5986
  format: localeFormat.format,
5984
5987
  isAutoSummable: true,
5985
5988
  defaultAlign: "right",
@@ -8470,8 +8473,8 @@ function truncateLabel(label) {
8470
8473
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
8471
8474
  const options = {
8472
8475
  // https://www.chartjs.org/docs/latest/general/responsive.html
8473
- responsive: true,
8474
- maintainAspectRatio: false,
8476
+ responsive: true, // will resize when its container is resized
8477
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
8475
8478
  layout: {
8476
8479
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
8477
8480
  },
@@ -8517,7 +8520,7 @@ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, tr
8517
8520
  labels: truncateLabels ? labels.map(truncateLabel) : labels,
8518
8521
  datasets: [],
8519
8522
  },
8520
- platform: undefined,
8523
+ platform: undefined, // This key is optional and will be set by chart.js
8521
8524
  plugins: [],
8522
8525
  };
8523
8526
  }
@@ -8781,7 +8784,7 @@ function getBarConfiguration(chart, labels, localeFormat) {
8781
8784
  },
8782
8785
  y: {
8783
8786
  position: chart.verticalAxisPosition,
8784
- beginAtZero: true,
8787
+ beginAtZero: true, // the origin of the y axis is always zero
8785
8788
  ticks: {
8786
8789
  color: fontColor,
8787
8790
  callback: (value) => {
@@ -9435,7 +9438,7 @@ function getLineConfiguration(chart, labels, options) {
9435
9438
  },
9436
9439
  y: {
9437
9440
  position: chart.verticalAxisPosition,
9438
- beginAtZero: true,
9441
+ beginAtZero: true, // the origin of the y axis is always zero
9439
9442
  ticks: {
9440
9443
  color: fontColor,
9441
9444
  callback: (value) => {
@@ -9523,7 +9526,7 @@ function createLineChartRuntime(chart, getters) {
9523
9526
  const dataset = {
9524
9527
  label,
9525
9528
  data,
9526
- tension: 0,
9529
+ tension: 0, // 0 -> render straight lines, which is much faster
9527
9530
  borderColor: color,
9528
9531
  backgroundColor,
9529
9532
  pointBackgroundColor: color,
@@ -9634,7 +9637,7 @@ class PieChart extends AbstractChart {
9634
9637
  ...this.getDefinition(),
9635
9638
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
9636
9639
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
9637
- verticalAxisPosition: "left",
9640
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
9638
9641
  dataSets,
9639
9642
  labelRange,
9640
9643
  };
@@ -27201,7 +27204,9 @@ class Composer extends Component {
27201
27204
  argToFocus: 0,
27202
27205
  });
27203
27206
  compositionActive = false;
27207
+ spreadsheetRect = useSpreadsheetRect();
27204
27208
  get assistantStyle() {
27209
+ const composerRect = this.composerRef.el.getBoundingClientRect();
27205
27210
  const assistantStyle = {};
27206
27211
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
27207
27212
  if (this.autoCompleteState.type === "function") {
@@ -27224,6 +27229,10 @@ class Composer extends Component {
27224
27229
  assistantStyle.right = `0px`;
27225
27230
  }
27226
27231
  }
27232
+ if (this.props.focus === "contentFocus" &&
27233
+ composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
27234
+ assistantStyle.right = "0px";
27235
+ }
27227
27236
  return cssPropertiesToCss(assistantStyle);
27228
27237
  }
27229
27238
  // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent
@@ -30057,7 +30066,7 @@ class VerticalScrollBar extends Component {
30057
30066
  onScroll(offset) {
30058
30067
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
30059
30068
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
30060
- offsetX: scrollX,
30069
+ offsetX: scrollX, // offsetX is the same
30061
30070
  offsetY: offset,
30062
30071
  });
30063
30072
  }
@@ -30270,8 +30279,8 @@ class Grid extends Component {
30270
30279
  "Ctrl+Shift+L": () => this.setHorizontalAlign("left"),
30271
30280
  "Ctrl+Shift+R": () => this.setHorizontalAlign("right"),
30272
30281
  "Ctrl+Shift+V": () => PASTE_AS_VALUE_ACTION(this.env),
30273
- "Ctrl+Shift+<": () => this.clearFormatting(),
30274
- "Ctrl+<": () => this.clearFormatting(),
30282
+ "Ctrl+Shift+<": () => this.clearFormatting(), // for qwerty
30283
+ "Ctrl+<": () => this.clearFormatting(), // for azerty
30275
30284
  "Ctrl+Shift+ ": () => {
30276
30285
  this.env.model.selection.selectAll();
30277
30286
  },
@@ -31069,10 +31078,10 @@ function convertCFCellIsOperator(xlsxCfOperator) {
31069
31078
  const CF_TYPE_CONVERSION_MAP = {
31070
31079
  aboveAverage: undefined,
31071
31080
  expression: undefined,
31072
- cellIs: undefined,
31073
- colorScale: undefined,
31081
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
31082
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
31074
31083
  dataBar: undefined,
31075
- iconSet: undefined,
31084
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
31076
31085
  top10: undefined,
31077
31086
  uniqueValues: undefined,
31078
31087
  duplicateValues: undefined,
@@ -31307,7 +31316,7 @@ const XLSX_INDEXED_COLORS = {
31307
31316
  61: "993366",
31308
31317
  62: "333399",
31309
31318
  63: "333333",
31310
- 64: "000000",
31319
+ 64: "000000", // system foreground
31311
31320
  65: "FFFFFF", // system background
31312
31321
  };
31313
31322
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34977,12 +34986,13 @@ class BordersPlugin extends CorePlugin {
34977
34986
  this.clearBorders(cmd.sheetId, cmd.target);
34978
34987
  break;
34979
34988
  case "REMOVE_COLUMNS_ROWS":
34980
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
34989
+ const elements = [...cmd.elements].sort((a, b) => b - a);
34990
+ for (const group of groupConsecutive(elements)) {
34981
34991
  if (cmd.dimension === "COL") {
34982
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34992
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34983
34993
  }
34984
34994
  else {
34985
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34995
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34986
34996
  }
34987
34997
  }
34988
34998
  break;
@@ -40014,12 +40024,7 @@ class SheetPlugin extends CorePlugin {
40014
40024
  });
40015
40025
  }
40016
40026
  if (colIndex > deletedColumn) {
40017
- this.dispatch("UPDATE_CELL_POSITION", {
40018
- sheetId: sheet.id,
40019
- cellId: cellId,
40020
- col: colIndex - 1,
40021
- row: rowIndex,
40022
- });
40027
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
40023
40028
  }
40024
40029
  }
40025
40030
  }
@@ -40029,7 +40034,7 @@ class SheetPlugin extends CorePlugin {
40029
40034
  * Move the cells after a column or rows insertion
40030
40035
  */
40031
40036
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
40032
- const commands = [];
40037
+ const updates = [];
40033
40038
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
40034
40039
  const row = sheet.rows[rowIndex];
40035
40040
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -40038,20 +40043,20 @@ class SheetPlugin extends CorePlugin {
40038
40043
  const cellId = row.cells[i];
40039
40044
  if (cellId) {
40040
40045
  if (dimension === "rows" || colIndex >= addedElement) {
40041
- commands.push({
40042
- type: "UPDATE_CELL_POSITION",
40046
+ updates.push({
40043
40047
  sheetId: sheet.id,
40044
40048
  cellId: cellId,
40045
40049
  col: colIndex + (dimension === "columns" ? quantity : 0),
40046
40050
  row: rowIndex + (dimension === "rows" ? quantity : 0),
40051
+ type: "UPDATE_CELL_POSITION",
40047
40052
  });
40048
40053
  }
40049
40054
  }
40050
40055
  }
40051
40056
  }
40052
40057
  }
40053
- for (let cmd of commands.reverse()) {
40054
- this.dispatch(cmd.type, cmd);
40058
+ for (let update of updates.reverse()) {
40059
+ this.updateCellPosition(update);
40055
40060
  }
40056
40061
  }
40057
40062
  /**
@@ -40084,12 +40089,7 @@ class SheetPlugin extends CorePlugin {
40084
40089
  const colIndex = Number(i);
40085
40090
  const cellId = row.cells[i];
40086
40091
  if (cellId) {
40087
- this.dispatch("UPDATE_CELL_POSITION", {
40088
- sheetId: sheet.id,
40089
- cellId: cellId,
40090
- col: colIndex,
40091
- row: rowIndex - numberRows,
40092
- });
40092
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
40093
40093
  }
40094
40094
  }
40095
40095
  }
@@ -42698,17 +42698,17 @@ function isBadExpression(tokens) {
42698
42698
  */
42699
42699
  function sortWithClusters(colorsToSort) {
42700
42700
  const clusters = [
42701
- { leadColor: rgba(255, 0, 0), colors: [] },
42702
- { leadColor: rgba(255, 128, 0), colors: [] },
42703
- { leadColor: rgba(128, 128, 0), colors: [] },
42704
- { leadColor: rgba(128, 255, 0), colors: [] },
42705
- { leadColor: rgba(0, 255, 0), colors: [] },
42706
- { leadColor: rgba(0, 255, 128), colors: [] },
42707
- { leadColor: rgba(0, 255, 255), colors: [] },
42708
- { leadColor: rgba(0, 127, 255), colors: [] },
42709
- { leadColor: rgba(0, 0, 255), colors: [] },
42710
- { leadColor: rgba(127, 0, 255), colors: [] },
42711
- { leadColor: rgba(128, 0, 128), colors: [] },
42701
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
42702
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
42703
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
42704
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
42705
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
42706
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
42707
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
42708
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
42709
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
42710
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
42711
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
42712
42712
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42713
42713
  ];
42714
42714
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -52495,7 +52495,7 @@ class BottomBar extends Component {
52495
52495
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52496
52496
  .map((rect) => ({
52497
52497
  x: rect.x,
52498
- width: rect.width - 1,
52498
+ width: rect.width - 1, // -1 to compensate negative margin
52499
52499
  y: rect.y,
52500
52500
  height: rect.height,
52501
52501
  }));
@@ -52717,7 +52717,7 @@ class RowGroup extends AbstractHeaderGroup {
52717
52717
  }
52718
52718
  return cssPropertiesToCss({
52719
52719
  top: `${groupBox.headerRect.height / 2}px`,
52720
- left: `calc(50% - 1px)`,
52720
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52721
52721
  width: `30%`,
52722
52722
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52723
52723
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52769,7 +52769,7 @@ class ColGroup extends AbstractHeaderGroup {
52769
52769
  return "";
52770
52770
  }
52771
52771
  return cssPropertiesToCss({
52772
- top: `calc(50% - 1px)`,
52772
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52773
52773
  left: `${groupBox.headerRect.width / 2}px`,
52774
52774
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52775
52775
  height: `30%`,
@@ -54180,7 +54180,7 @@ class Spreadsheet extends Component {
54180
54180
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
54181
54181
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
54182
54182
  return cssPropertiesToCss({
54183
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
54183
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
54184
54184
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
54185
54185
  });
54186
54186
  }
@@ -55625,7 +55625,7 @@ class SelectionStreamProcessorImpl {
55625
55625
  }
55626
55626
 
55627
55627
  class StateObserver {
55628
- changes = [];
55628
+ changes;
55629
55629
  commands = [];
55630
55630
  /**
55631
55631
  * Record the changes which could happen in the given callback, save them in a
@@ -55657,7 +55657,7 @@ class StateObserver {
55657
55657
  if (value[key] === val) {
55658
55658
  return;
55659
55659
  }
55660
- this.changes.push({
55660
+ this.changes?.push({
55661
55661
  path: args,
55662
55662
  before: value[key],
55663
55663
  after: val,
@@ -56788,7 +56788,7 @@ function addTableColumns(table, sheetData) {
56788
56788
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56789
56789
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56790
56790
  const colAttributes = [
56791
- ["id", i + 1],
56791
+ ["id", i + 1], // id cannot be 0
56792
56792
  ["name", colName],
56793
56793
  ];
56794
56794
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57844,6 +57844,6 @@ const constants = {
57844
57844
  export { AbstractChart, CellErrorType, 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 };
57845
57845
 
57846
57846
 
57847
- __info__.version = "17.1.25";
57848
- __info__.date = "2024-07-24T10:26:01.576Z";
57849
- __info__.hash = "0edff47";
57847
+ __info__.version = "17.1.26";
57848
+ __info__.date = "2024-08-02T08:23:08.499Z";
57849
+ __info__.hash = "4ba7e55";