@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
  'use strict';
@@ -594,7 +594,7 @@ function debounce(func, wait, immediate) {
594
594
  let timeout;
595
595
  return function () {
596
596
  const context = this;
597
- const args = arguments;
597
+ const args = Array.from(arguments);
598
598
  function later() {
599
599
  timeout = null;
600
600
  if (!immediate) {
@@ -797,7 +797,7 @@ function isNumberBetween(value, min, max) {
797
797
  */
798
798
  function largeMax(array) {
799
799
  let len = array.length;
800
- if (len < 100000)
800
+ if (len < 100_000)
801
801
  return Math.max(...array);
802
802
  let max = -Infinity;
803
803
  while (len--) {
@@ -811,7 +811,7 @@ function largeMax(array) {
811
811
  */
812
812
  function largeMin(array) {
813
813
  let len = array.length;
814
- if (len < 100000)
814
+ if (len < 100_000)
815
815
  return Math.min(...array);
816
816
  let min = +Infinity;
817
817
  while (len--) {
@@ -2566,13 +2566,16 @@ function operandToRegExp(operand) {
2566
2566
  }
2567
2567
  return new RegExp("^" + exp + "$", "i");
2568
2568
  }
2569
- function evaluatePredicate(value = "", criterion) {
2569
+ function evaluatePredicate(value = "", criterion, locale) {
2570
2570
  const { operator, operand } = criterion;
2571
2571
  if (operand === undefined || value === null || operand === null) {
2572
2572
  return false;
2573
2573
  }
2574
2574
  if (typeof operand === "number" && operator === "=") {
2575
- return toString(value) === toString(operand);
2575
+ if (typeof value === "string" && (isNumber(value, locale) || isDateTime(value, locale))) {
2576
+ return toNumber(value, locale) === operand;
2577
+ }
2578
+ return value === operand;
2576
2579
  }
2577
2580
  if (operator === "<>" || operator === "=") {
2578
2581
  let result;
@@ -2651,7 +2654,7 @@ function visitMatchingRanges(args, cb, locale, isQuery = false) {
2651
2654
  for (let k = 0; k < countArg - 1; k += 2) {
2652
2655
  const criteriaValue = args[k][i][j];
2653
2656
  const criterion = predicates[k / 2];
2654
- validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2657
+ validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion, locale);
2655
2658
  if (!validatedPredicates) {
2656
2659
  break;
2657
2660
  }
@@ -5900,7 +5903,7 @@ function textCell(value, localeFormat) {
5900
5903
  function numberCell(value, localeFormat) {
5901
5904
  return {
5902
5905
  type: CellValueType.number,
5903
- value: value || 0,
5906
+ value: value || 0, // necessary to avoid "-0" and NaN values,
5904
5907
  format: localeFormat.format,
5905
5908
  isAutoSummable: true,
5906
5909
  defaultAlign: "right",
@@ -8433,8 +8436,8 @@ function truncateLabel(label) {
8433
8436
  function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale, truncateLabels = true }) {
8434
8437
  const options = {
8435
8438
  // https://www.chartjs.org/docs/latest/general/responsive.html
8436
- responsive: true,
8437
- maintainAspectRatio: false,
8439
+ responsive: true, // will resize when its container is resized
8440
+ maintainAspectRatio: false, // doesn't maintain the aspect ration (width/height =2 by default) so the user has the choice of the exact layout
8438
8441
  layout: {
8439
8442
  padding: { left: 20, right: 20, top: chart.title ? 10 : 25, bottom: 10 },
8440
8443
  },
@@ -8743,7 +8746,7 @@ function getBarConfiguration(chart, labels, localeFormat) {
8743
8746
  },
8744
8747
  y: {
8745
8748
  position: chart.verticalAxisPosition,
8746
- beginAtZero: true,
8749
+ beginAtZero: true, // the origin of the y axis is always zero
8747
8750
  ticks: {
8748
8751
  color: fontColor,
8749
8752
  callback: (value) => {
@@ -9397,7 +9400,7 @@ function getLineConfiguration(chart, labels, options) {
9397
9400
  },
9398
9401
  y: {
9399
9402
  position: chart.verticalAxisPosition,
9400
- beginAtZero: true,
9403
+ beginAtZero: true, // the origin of the y axis is always zero
9401
9404
  ticks: {
9402
9405
  color: fontColor,
9403
9406
  callback: (value) => {
@@ -9485,7 +9488,7 @@ function createLineChartRuntime(chart, getters) {
9485
9488
  const dataset = {
9486
9489
  label,
9487
9490
  data,
9488
- tension: 0,
9491
+ tension: 0, // 0 -> render straight lines, which is much faster
9489
9492
  borderColor: color,
9490
9493
  backgroundColor,
9491
9494
  pointBackgroundColor: color,
@@ -9596,7 +9599,7 @@ class PieChart extends AbstractChart {
9596
9599
  ...this.getDefinition(),
9597
9600
  backgroundColor: toXlsxHexColor(this.background || BACKGROUND_CHART_COLOR),
9598
9601
  fontColor: toXlsxHexColor(chartFontColor(this.background)),
9599
- verticalAxisPosition: "left",
9602
+ verticalAxisPosition: "left", //TODO ExcelChartDefinition should be adapted, but can be done later
9600
9603
  dataSets,
9601
9604
  labelRange,
9602
9605
  };
@@ -26700,7 +26703,9 @@ class Composer extends owl.Component {
26700
26703
  argToFocus: 0,
26701
26704
  });
26702
26705
  compositionActive = false;
26706
+ spreadsheetRect = useSpreadsheetRect();
26703
26707
  get assistantStyle() {
26708
+ const composerRect = this.composerRef.el.getBoundingClientRect();
26704
26709
  const assistantStyle = {};
26705
26710
  assistantStyle["min-width"] = `${this.props.rect?.width || ASSISTANT_WIDTH}px`;
26706
26711
  if (this.autoCompleteState.type === "function") {
@@ -26723,6 +26728,10 @@ class Composer extends owl.Component {
26723
26728
  assistantStyle.right = `0px`;
26724
26729
  }
26725
26730
  }
26731
+ if (this.props.focus === "contentFocus" &&
26732
+ composerRect.left + ASSISTANT_WIDTH > this.spreadsheetRect.width) {
26733
+ assistantStyle.right = "0px";
26734
+ }
26726
26735
  return cssPropertiesToCss(assistantStyle);
26727
26736
  }
26728
26737
  // we can't allow input events to be triggered while we remove and add back the content of the composer in processContent
@@ -29581,7 +29590,7 @@ class VerticalScrollBar extends owl.Component {
29581
29590
  onScroll(offset) {
29582
29591
  const { scrollX } = this.env.model.getters.getActiveSheetDOMScrollInfo();
29583
29592
  this.env.model.dispatch("SET_VIEWPORT_OFFSET", {
29584
- offsetX: scrollX,
29593
+ offsetX: scrollX, // offsetX is the same
29585
29594
  offsetY: offset,
29586
29595
  });
29587
29596
  }
@@ -29792,8 +29801,8 @@ class Grid extends owl.Component {
29792
29801
  "CTRL+SHIFT+L": () => this.setHorizontalAlign("left"),
29793
29802
  "CTRL+SHIFT+R": () => this.setHorizontalAlign("right"),
29794
29803
  "CTRL+SHIFT+V": () => PASTE_VALUE_ACTION(this.env),
29795
- "CTRL+SHIFT+<": () => this.clearFormatting(),
29796
- "CTRL+<": () => this.clearFormatting(),
29804
+ "CTRL+SHIFT+<": () => this.clearFormatting(), // for qwerty
29805
+ "CTRL+<": () => this.clearFormatting(), // for azerty
29797
29806
  "CTRL+SHIFT+ ": () => {
29798
29807
  this.env.model.selection.selectAll();
29799
29808
  },
@@ -30607,10 +30616,10 @@ function convertCFCellIsOperator(xlsxCfOperator) {
30607
30616
  const CF_TYPE_CONVERSION_MAP = {
30608
30617
  aboveAverage: undefined,
30609
30618
  expression: undefined,
30610
- cellIs: undefined,
30611
- colorScale: undefined,
30619
+ cellIs: undefined, // exist but isn't an operator in o_spreadsheet
30620
+ colorScale: undefined, // exist but isn't an operator in o_spreadsheet
30612
30621
  dataBar: undefined,
30613
- iconSet: undefined,
30622
+ iconSet: undefined, // exist but isn't an operator in o_spreadsheet
30614
30623
  top10: undefined,
30615
30624
  uniqueValues: undefined,
30616
30625
  duplicateValues: undefined,
@@ -30845,7 +30854,7 @@ const XLSX_INDEXED_COLORS = {
30845
30854
  61: "993366",
30846
30855
  62: "333399",
30847
30856
  63: "333333",
30848
- 64: "000000",
30857
+ 64: "000000", // system foreground
30849
30858
  65: "FFFFFF", // system background
30850
30859
  };
30851
30860
  const IMAGE_MIMETYPE_TO_EXTENSION_MAPPING = {
@@ -34486,12 +34495,13 @@ class BordersPlugin extends CorePlugin {
34486
34495
  this.clearBorders(cmd.sheetId, cmd.target);
34487
34496
  break;
34488
34497
  case "REMOVE_COLUMNS_ROWS":
34489
- for (let el of [...cmd.elements].sort((a, b) => b - a)) {
34498
+ const elements = [...cmd.elements].sort((a, b) => b - a);
34499
+ for (const group of groupConsecutive(elements)) {
34490
34500
  if (cmd.dimension === "COL") {
34491
- this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
34501
+ this.shiftBordersHorizontally(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34492
34502
  }
34493
34503
  else {
34494
- this.shiftBordersVertically(cmd.sheetId, el + 1, -1);
34504
+ this.shiftBordersVertically(cmd.sheetId, group[group.length - 1] + 1, -group.length);
34495
34505
  }
34496
34506
  }
34497
34507
  break;
@@ -39552,12 +39562,7 @@ class SheetPlugin extends CorePlugin {
39552
39562
  });
39553
39563
  }
39554
39564
  if (colIndex > deletedColumn) {
39555
- this.dispatch("UPDATE_CELL_POSITION", {
39556
- sheetId: sheet.id,
39557
- cellId: cellId,
39558
- col: colIndex - 1,
39559
- row: rowIndex,
39560
- });
39565
+ this.setNewPosition(cellId, sheet.id, colIndex - 1, rowIndex);
39561
39566
  }
39562
39567
  }
39563
39568
  }
@@ -39567,7 +39572,7 @@ class SheetPlugin extends CorePlugin {
39567
39572
  * Move the cells after a column or rows insertion
39568
39573
  */
39569
39574
  moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
39570
- const commands = [];
39575
+ const updates = [];
39571
39576
  for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
39572
39577
  const row = sheet.rows[rowIndex];
39573
39578
  if (dimension !== "rows" || rowIndex >= addedElement) {
@@ -39576,20 +39581,20 @@ class SheetPlugin extends CorePlugin {
39576
39581
  const cellId = row.cells[i];
39577
39582
  if (cellId) {
39578
39583
  if (dimension === "rows" || colIndex >= addedElement) {
39579
- commands.push({
39580
- type: "UPDATE_CELL_POSITION",
39584
+ updates.push({
39581
39585
  sheetId: sheet.id,
39582
39586
  cellId: cellId,
39583
39587
  col: colIndex + (dimension === "columns" ? quantity : 0),
39584
39588
  row: rowIndex + (dimension === "rows" ? quantity : 0),
39589
+ type: "UPDATE_CELL_POSITION",
39585
39590
  });
39586
39591
  }
39587
39592
  }
39588
39593
  }
39589
39594
  }
39590
39595
  }
39591
- for (let cmd of commands.reverse()) {
39592
- this.dispatch(cmd.type, cmd);
39596
+ for (let update of updates.reverse()) {
39597
+ this.updateCellPosition(update);
39593
39598
  }
39594
39599
  }
39595
39600
  /**
@@ -39622,12 +39627,7 @@ class SheetPlugin extends CorePlugin {
39622
39627
  const colIndex = Number(i);
39623
39628
  const cellId = row.cells[i];
39624
39629
  if (cellId) {
39625
- this.dispatch("UPDATE_CELL_POSITION", {
39626
- sheetId: sheet.id,
39627
- cellId: cellId,
39628
- col: colIndex,
39629
- row: rowIndex - numberRows,
39630
- });
39630
+ this.setNewPosition(cellId, sheet.id, colIndex, rowIndex - numberRows);
39631
39631
  }
39632
39632
  }
39633
39633
  }
@@ -42240,17 +42240,17 @@ function isBadExpression(tokens) {
42240
42240
  */
42241
42241
  function sortWithClusters(colorsToSort) {
42242
42242
  const clusters = [
42243
- { leadColor: rgba(255, 0, 0), colors: [] },
42244
- { leadColor: rgba(255, 128, 0), colors: [] },
42245
- { leadColor: rgba(128, 128, 0), colors: [] },
42246
- { leadColor: rgba(128, 255, 0), colors: [] },
42247
- { leadColor: rgba(0, 255, 0), colors: [] },
42248
- { leadColor: rgba(0, 255, 128), colors: [] },
42249
- { leadColor: rgba(0, 255, 255), colors: [] },
42250
- { leadColor: rgba(0, 127, 255), colors: [] },
42251
- { leadColor: rgba(0, 0, 255), colors: [] },
42252
- { leadColor: rgba(127, 0, 255), colors: [] },
42253
- { leadColor: rgba(128, 0, 128), colors: [] },
42243
+ { leadColor: rgba(255, 0, 0), colors: [] }, // red
42244
+ { leadColor: rgba(255, 128, 0), colors: [] }, // orange
42245
+ { leadColor: rgba(128, 128, 0), colors: [] }, // yellow
42246
+ { leadColor: rgba(128, 255, 0), colors: [] }, // chartreuse
42247
+ { leadColor: rgba(0, 255, 0), colors: [] }, // green
42248
+ { leadColor: rgba(0, 255, 128), colors: [] }, // spring green
42249
+ { leadColor: rgba(0, 255, 255), colors: [] }, // cyan
42250
+ { leadColor: rgba(0, 127, 255), colors: [] }, // azure
42251
+ { leadColor: rgba(0, 0, 255), colors: [] }, // blue
42252
+ { leadColor: rgba(127, 0, 255), colors: [] }, // violet
42253
+ { leadColor: rgba(128, 0, 128), colors: [] }, // magenta
42254
42254
  { leadColor: rgba(255, 0, 128), colors: [] }, // rose
42255
42255
  ];
42256
42256
  for (const color of colorsToSort.map(colorToRGBA)) {
@@ -52160,7 +52160,7 @@ class BottomBar extends owl.Component {
52160
52160
  .map((sheetEl) => sheetEl.getBoundingClientRect())
52161
52161
  .map((rect) => ({
52162
52162
  x: rect.x,
52163
- width: rect.width - 1,
52163
+ width: rect.width - 1, // -1 to compensate negative margin
52164
52164
  y: rect.y,
52165
52165
  height: rect.height,
52166
52166
  }));
@@ -52385,7 +52385,7 @@ class RowGroup extends AbstractHeaderGroup {
52385
52385
  }
52386
52386
  return cssPropertiesToCss({
52387
52387
  top: `${groupBox.headerRect.height / 2}px`,
52388
- left: `calc(50% - 1px)`,
52388
+ left: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52389
52389
  width: `30%`,
52390
52390
  height: `calc(100% - ${groupBox.headerRect.height / 2}px)`,
52391
52391
  "border-left": `1px solid ${HEADER_GROUPING_BORDER_COLOR}`,
@@ -52437,7 +52437,7 @@ class ColGroup extends AbstractHeaderGroup {
52437
52437
  return "";
52438
52438
  }
52439
52439
  return cssPropertiesToCss({
52440
- top: `calc(50% - 1px)`,
52440
+ top: `calc(50% - 1px)`, // -1px: we want the border to be on the center
52441
52441
  left: `${groupBox.headerRect.width / 2}px`,
52442
52442
  width: `calc(100% - ${groupBox.headerRect.width / 2}px)`,
52443
52443
  height: `30%`,
@@ -53838,7 +53838,7 @@ class Spreadsheet extends owl.Component {
53838
53838
  const gridColSize = GROUP_LAYER_WIDTH * this.rowLayers.length;
53839
53839
  const gridRowSize = GROUP_LAYER_WIDTH * this.colLayers.length;
53840
53840
  return cssPropertiesToCss({
53841
- "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`,
53841
+ "grid-template-columns": `${gridColSize ? gridColSize + 2 : 0}px auto`, // +2: margins
53842
53842
  "grid-template-rows": `${gridRowSize ? gridRowSize + 2 : 0}px auto`,
53843
53843
  });
53844
53844
  }
@@ -55341,7 +55341,7 @@ class SelectionStreamProcessorImpl {
55341
55341
  }
55342
55342
 
55343
55343
  class StateObserver {
55344
- changes = [];
55344
+ changes;
55345
55345
  commands = [];
55346
55346
  /**
55347
55347
  * Record the changes which could happen in the given callback, save them in a
@@ -55373,7 +55373,7 @@ class StateObserver {
55373
55373
  if (value[key] === val) {
55374
55374
  return;
55375
55375
  }
55376
- this.changes.push({
55376
+ this.changes?.push({
55377
55377
  path: args,
55378
55378
  before: value[key],
55379
55379
  after: val,
@@ -56504,7 +56504,7 @@ function addTableColumns(table, sheetData) {
56504
56504
  const colHeaderXc = toXC(tableZone.left + i, tableZone.top);
56505
56505
  const colName = sheetData.cells[colHeaderXc]?.content || `col${i}`;
56506
56506
  const colAttributes = [
56507
- ["id", i + 1],
56507
+ ["id", i + 1], // id cannot be 0
56508
56508
  ["name", colName],
56509
56509
  ];
56510
56510
  columns.push(escapeXml /*xml*/ `<tableColumn ${formatAttributes(colAttributes)}/>`);
@@ -57586,6 +57586,6 @@ exports.setTranslationMethod = setTranslationMethod;
57586
57586
  exports.tokenize = tokenize;
57587
57587
 
57588
57588
 
57589
- __info__.version = "17.0.32";
57590
- __info__.date = "2024-07-24T10:26:05.203Z";
57591
- __info__.hash = "679a547";
57589
+ __info__.version = "17.0.33";
57590
+ __info__.date = "2024-08-02T08:18:55.061Z";
57591
+ __info__.hash = "4ad4049";
@@ -7250,6 +7250,7 @@ declare class Composer extends Component<ComposerProps, SpreadsheetChildEnv> {
7250
7250
  autoCompleteState: AutoCompleteState;
7251
7251
  functionDescriptionState: FunctionDescriptionState;
7252
7252
  private compositionActive;
7253
+ private spreadsheetRect;
7253
7254
  get assistantStyle(): string;
7254
7255
  shouldProcessInputEvents: boolean;
7255
7256
  tokens: EnrichedToken[];
@@ -7438,7 +7439,7 @@ declare class Spreadsheet extends Component<SpreadsheetProps, SpreadsheetChildEn
7438
7439
  private keyDownMapping;
7439
7440
  private isViewportTooSmall;
7440
7441
  get model(): Model;
7441
- getStyle(): string;
7442
+ getStyle(): "grid-template-rows: auto;" | "grid-template-rows: 63px auto 37px";
7442
7443
  setup(): void;
7443
7444
  get focusTopBarComposer(): Omit<ComposerFocusType, "cellFocus">;
7444
7445
  get focusGridComposer(): ComposerFocusType;