@odoo/o-spreadsheet 17.1.24 → 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.24
6
- * @date 2024-07-18T14:21:58.787Z
7
- * @hash 46a558e
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
@@ -28869,10 +28878,13 @@ function useCellHovered(env, gridRef, callback) {
28869
28878
  row: undefined,
28870
28879
  };
28871
28880
  const { Date } = window;
28872
- let x = 0;
28873
- let y = 0;
28881
+ let x = undefined;
28882
+ let y = undefined;
28874
28883
  let lastMoved = 0;
28875
28884
  function getPosition() {
28885
+ if (x === undefined || y === undefined) {
28886
+ return { col: -1, row: -1 };
28887
+ }
28876
28888
  const col = env.model.getters.getColIndex(x);
28877
28889
  const row = env.model.getters.getRowIndex(y);
28878
28890
  return { col, row };
@@ -30054,7 +30066,7 @@ class VerticalScrollBar extends Component {
30054
30066
  onScroll(offset) {
30055
30067
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
30056
30068
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
30057
- offsetX: scrollX,
30069
+ offsetX: scrollX, // offsetX is the same
30058
30070
  offsetY: offset,
30059
30071
  });
30060
30072
  }
@@ -30267,8 +30279,8 @@ class Grid extends Component {
30267
30279
  "Ctrl+Shift+L": () => this.setHorizontalAlign("left"),
30268
30280
  "Ctrl+Shift+R": () => this.setHorizontalAlign("right"),
30269
30281
  "Ctrl+Shift+V": () => PASTE_AS_VALUE_ACTION(this.env),
30270
- "Ctrl+Shift+<": () => this.clearFormatting(),
30271
- "Ctrl+<": () => this.clearFormatting(),
30282
+ "Ctrl+Shift+<": () => this.clearFormatting(), // for qwerty
30283
+ "Ctrl+<": () => this.clearFormatting(), // for azerty
30272
30284
  "Ctrl+Shift+ ": () => {
30273
30285
  this.env.model.selection.selectAll();
30274
30286
  },
@@ -31066,10 +31078,10 @@ function convertCFCellIsOperator(xlsxCfOperator) {
31066
31078
  const CF_TYPE_CONVERSION_MAP = {
31067
31079
  aboveAverage: undefined,
31068
31080
  expression: undefined,
31069
- cellIs: undefined,
31070
- 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
31071
31083
  dataBar: undefined,
31072
- iconSet: undefined,
31084
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
31073
31085
  top10: undefined,
31074
31086
  uniqueValues: undefined,
31075
31087
  duplicateValues: undefined,
@@ -31304,7 +31316,7 @@ const XLSX_INDEXED_COLORS = {
31304
31316
  61: "993366",
31305
31317
  62: "333399",
31306
31318
  63: "333333",
31307
- 64: "000000",
31319
+ 64: "000000", // system foreground
31308
31320
  65: "FFFFFF", // system background
31309
31321
  };
31310
31322
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34974,12 +34986,13 @@ class BordersPlugin extends CorePlugin {
34974
34986
  this.clearBorders(cmd.sheetId, cmd.target);
34975
34987
  break;
34976
34988
  case "REMOVE_COLUMNS_ROWS":
34977
- 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)) {
34978
34991
  if (cmd.dimension === "COL") {
34979
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34992
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34980
34993
  }
34981
34994
  else {
34982
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34995
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34983
34996
  }
34984
34997
  }
34985
34998
  break;
@@ -40011,12 +40024,7 @@ class SheetPlugin extends CorePlugin {
40011
40024
  });
40012
40025
  }
40013
40026
  if (colIndex > deletedColumn) {
40014
- this.dispatch("UPDATE_CELL_POSITION", {
40015
- sheetId: sheet.id,
40016
- cellId: cellId,
40017
- col: colIndex - 1,
40018
- row: rowIndex,
40019
- });
40027
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
40020
40028
  }
40021
40029
  }
40022
40030
  }
@@ -40026,7 +40034,7 @@ class SheetPlugin extends CorePlugin {
40026
40034
  * Move the cells after a column or rows insertion
40027
40035
  */
40028
40036
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
40029
- const commands = [];
40037
+ const updates = [];
40030
40038
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
40031
40039
  const row = sheet.rows[rowIndex];
40032
40040
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -40035,20 +40043,20 @@ class SheetPlugin extends CorePlugin {
40035
40043
  const cellId = row.cells[i];
40036
40044
  if (cellId) {
40037
40045
  if (dimension === "rows" || colIndex >= addedElement) {
40038
- commands.push({
40039
- type: "UPDATE_CELL_POSITION",
40046
+ updates.push({
40040
40047
  sheetId: sheet.id,
40041
40048
  cellId: cellId,
40042
40049
  col: colIndex + (dimension === "columns" ? quantity : 0),
40043
40050
  row: rowIndex + (dimension === "rows" ? quantity : 0),
40051
+ type: "UPDATE_CELL_POSITION",
40044
40052
  });
40045
40053
  }
40046
40054
  }
40047
40055
  }
40048
40056
  }
40049
40057
  }
40050
- for (let cmd of commands.reverse()) {
40051
- this.dispatch(cmd.type, cmd);
40058
+ for (let update of updates.reverse()) {
40059
+ this.updateCellPosition(update);
40052
40060
  }
40053
40061
  }
40054
40062
  /**
@@ -40081,12 +40089,7 @@ class SheetPlugin extends CorePlugin {
40081
40089
  const colIndex = Number(i);
40082
40090
  const cellId = row.cells[i];
40083
40091
  if (cellId) {
40084
- this.dispatch("UPDATE_CELL_POSITION", {
40085
- sheetId: sheet.id,
40086
- cellId: cellId,
40087
- col: colIndex,
40088
- row: rowIndex - numberRows,
40089
- });
40092
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
40090
40093
  }
40091
40094
  }
40092
40095
  }
@@ -42695,17 +42698,17 @@ function isBadExpression(tokens) {
42695
42698
  */
42696
42699
  function sortWithClusters(colorsToSort) {
42697
42700
  const clusters = [
42698
- { leadColor: rgba(255, 0, 0), colors: [] },
42699
- { leadColor: rgba(255, 128, 0), colors: [] },
42700
- { leadColor: rgba(128, 128, 0), colors: [] },
42701
- { leadColor: rgba(128, 255, 0), colors: [] },
42702
- { leadColor: rgba(0, 255, 0), colors: [] },
42703
- { leadColor: rgba(0, 255, 128), colors: [] },
42704
- { leadColor: rgba(0, 255, 255), colors: [] },
42705
- { leadColor: rgba(0, 127, 255), colors: [] },
42706
- { leadColor: rgba(0, 0, 255), colors: [] },
42707
- { leadColor: rgba(127, 0, 255), colors: [] },
42708
- { 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
42709
42712
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42710
42713
  ];
42711
42714
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -52492,7 +52495,7 @@ class BottomBar extends Component {
52492
52495
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52493
52496
  .map((rect) => ({
52494
52497
  x: rect.x,
52495
- width: rect.width - 1,
52498
+ width: rect.width - 1, // -1 to compensate negative margin
52496
52499
  y: rect.y,
52497
52500
  height: rect.height,
52498
52501
  }));
@@ -52714,7 +52717,7 @@ class RowGroup extends AbstractHeaderGroup {
52714
52717
  }
52715
52718
  return cssPropertiesToCss({
52716
52719
  top: `${groupBox.headerRect.height / 2}px`,
52717
- left: `calc(50% - 1px)`,
52720
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52718
52721
  width: `30%`,
52719
52722
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52720
52723
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52766,7 +52769,7 @@ class ColGroup extends AbstractHeaderGroup {
52766
52769
  return "";
52767
52770
  }
52768
52771
  return cssPropertiesToCss({
52769
- top: `calc(50% - 1px)`,
52772
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52770
52773
  left: `${groupBox.headerRect.width / 2}px`,
52771
52774
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52772
52775
  height: `30%`,
@@ -54177,7 +54180,7 @@ class Spreadsheet extends Component {
54177
54180
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
54178
54181
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
54179
54182
  return cssPropertiesToCss({
54180
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
54183
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
54181
54184
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
54182
54185
  });
54183
54186
  }
@@ -55622,7 +55625,7 @@ class SelectionStreamProcessorImpl {
55622
55625
  }
55623
55626
 
55624
55627
  class StateObserver {
55625
- changes = [];
55628
+ changes;
55626
55629
  commands = [];
55627
55630
  /**
55628
55631
  * Record the changes which could happen in the given callback, save them in a
@@ -55654,7 +55657,7 @@ class StateObserver {
55654
55657
  if (value[key] === val) {
55655
55658
  return;
55656
55659
  }
55657
- this.changes.push({
55660
+ this.changes?.push({
55658
55661
  path: args,
55659
55662
  before: value[key],
55660
55663
  after: val,
@@ -56785,7 +56788,7 @@ function addTableColumns(table, sheetData) {
56785
56788
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56786
56789
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56787
56790
  const colAttributes = [
56788
- ["id", i + 1],
56791
+ ["id", i + 1], // id cannot be 0
56789
56792
  ["name", colName],
56790
56793
  ];
56791
56794
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57841,6 +57844,6 @@ const constants = {
57841
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 };
57842
57845
 
57843
57846
 
57844
- __info__.version = "17.1.24";
57845
- __info__.date = "2024-07-18T14:21:58.787Z";
57846
- __info__.hash = "46a558e";
57847
+ __info__.version = "17.1.26";
57848
+ __info__.date = "2024-08-02T08:23:08.499Z";
57849
+ __info__.hash = "4ba7e55";