@odoo/o-spreadsheet 17.2.32 → 17.2.34

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.32
7
- * @date 2025-01-15T08:03:19.290Z
8
- * @hash e12286d
6
+ * @version 17.2.34
7
+ * @date 2025-01-31T07:58:03.953Z
8
+ * @hash 0bffee9
9
9
  */
10
10
 
11
11
  'use strict';
@@ -1784,11 +1784,11 @@ const getInvaluableSymbolsRegexp = memoize(function getInvaluableSymbolsRegexp(l
1784
1784
  * number from the point of view of the isNumber function.
1785
1785
  */
1786
1786
  function parseNumber(str, locale) {
1787
+ // remove invaluable characters
1788
+ str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1787
1789
  if (locale.decimalSeparator !== ".") {
1788
1790
  str = str.replace(locale.decimalSeparator, ".");
1789
1791
  }
1790
- // remove invaluable characters
1791
- str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1792
1792
  let n = Number(str);
1793
1793
  if (isNaN(n) && str.includes("%")) {
1794
1794
  n = Number(str.split("%")[0]);
@@ -2807,15 +2807,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2807
2807
  let currentIndex;
2808
2808
  let currentVal;
2809
2809
  let currentType;
2810
+ const getValue = sortOrder === "desc"
2811
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2812
+ : (i) => normalizeValue(getValueInData(data, i));
2810
2813
  while (indexRight - indexLeft >= 0) {
2811
2814
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2812
2815
  currentIndex = indexMedian;
2813
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2816
+ currentVal = getValue(currentIndex);
2814
2817
  currentType = typeof currentVal;
2815
2818
  // 1 - linear search to find value with the same type
2816
2819
  while (indexLeft < currentIndex && targetType !== currentType) {
2817
2820
  currentIndex--;
2818
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2821
+ currentVal = getValue(currentIndex);
2819
2822
  currentType = typeof currentVal;
2820
2823
  }
2821
2824
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2831,8 +2834,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2831
2834
  if (matchVal === undefined ||
2832
2835
  matchVal === null ||
2833
2836
  matchVal < currentVal ||
2834
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2835
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2837
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2836
2838
  matchVal = currentVal;
2837
2839
  matchValIndex = currentIndex;
2838
2840
  }
@@ -2840,15 +2842,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2840
2842
  else if (mode === "nextGreater" && currentVal >= _target) {
2841
2843
  if (matchVal === undefined ||
2842
2844
  matchVal > currentVal ||
2843
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2844
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2845
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2845
2846
  matchVal = currentVal;
2846
2847
  matchValIndex = currentIndex;
2847
2848
  }
2848
2849
  }
2849
2850
  // 3 - give new indexes for the Binary search
2850
- if ((sortOrder === "asc" && currentVal > _target) ||
2851
- (sortOrder === "desc" && currentVal <= _target)) {
2851
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2852
2852
  indexRight = currentIndex - 1;
2853
2853
  }
2854
2854
  else {
@@ -2856,7 +2856,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2856
2856
  }
2857
2857
  }
2858
2858
  // note that valMinIndex could be 0
2859
- return matchValIndex !== undefined ? matchValIndex : -1;
2859
+ if (matchValIndex === undefined) {
2860
+ return -1;
2861
+ }
2862
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2860
2863
  }
2861
2864
  /**
2862
2865
  * Perform a linear search and return the index of the match.
@@ -21877,6 +21880,10 @@ class Popover extends owl.Component {
21877
21880
  this.currentDisplayValue = newDisplay;
21878
21881
  if (!anchor)
21879
21882
  return;
21883
+ el.style.top = "";
21884
+ el.style.left = "";
21885
+ el.style["max-height"] = "";
21886
+ el.style["max-width"] = "";
21880
21887
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
21881
21888
  let elDims = {
21882
21889
  width: el.getBoundingClientRect().width,
@@ -32943,7 +32950,7 @@ class GridComposer extends owl.Component {
32943
32950
  return;
32944
32951
  }
32945
32952
  const sheetId = this.env.model.getters.getActiveSheetId();
32946
- const zone = this.env.model.getters.getSelectedZone();
32953
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
32947
32954
  const rect = this.env.model.getters.getVisibleRect(zone);
32948
32955
  if (!deepEquals(rect, this.rect) || sheetId !== this.composerStore.currentEditedCell.sheetId) {
32949
32956
  this.isCellReferenceVisible = true;
@@ -34689,13 +34696,23 @@ class GridRenderer {
34689
34696
  drawLayer(renderingContext, layer) {
34690
34697
  switch (layer) {
34691
34698
  case "Background":
34692
- const boxes = this.getGridBoxes();
34693
- this.drawBackground(renderingContext, boxes);
34694
- this.drawOverflowingCellBackground(renderingContext, boxes);
34695
- this.drawCellBackground(renderingContext, boxes);
34696
- this.drawBorders(renderingContext, boxes);
34697
- this.drawTexts(renderingContext, boxes);
34698
- this.drawIcon(renderingContext, boxes);
34699
+ this.drawGlobalBackground(renderingContext);
34700
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
34701
+ const { ctx } = renderingContext;
34702
+ ctx.save();
34703
+ ctx.beginPath();
34704
+ const rect = this.getters.getVisibleRect(zone);
34705
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
34706
+ ctx.clip();
34707
+ const boxes = this.getGridBoxes(zone);
34708
+ this.drawBackground(renderingContext, boxes);
34709
+ this.drawOverflowingCellBackground(renderingContext, boxes);
34710
+ this.drawCellBackground(renderingContext, boxes);
34711
+ this.drawBorders(renderingContext, boxes);
34712
+ this.drawTexts(renderingContext, boxes);
34713
+ this.drawIcon(renderingContext, boxes);
34714
+ ctx.restore();
34715
+ }
34699
34716
  this.drawFrozenPanes(renderingContext);
34700
34717
  break;
34701
34718
  case "Headers":
@@ -34706,12 +34723,15 @@ class GridRenderer {
34706
34723
  break;
34707
34724
  }
34708
34725
  }
34709
- drawBackground(renderingContext, boxes) {
34710
- const { ctx, thinLineWidth } = renderingContext;
34726
+ drawGlobalBackground(renderingContext) {
34727
+ const { ctx } = renderingContext;
34711
34728
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
34712
34729
  // white background
34713
34730
  ctx.fillStyle = "#ffffff";
34714
34731
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
34732
+ }
34733
+ drawBackground(renderingContext, boxes) {
34734
+ const { ctx, thinLineWidth } = renderingContext;
34715
34735
  const areGridLinesVisible = !this.getters.isDashboard() &&
34716
34736
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
34717
34737
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -35136,7 +35156,7 @@ class GridRenderer {
35136
35156
  const position = { sheetId, col, row };
35137
35157
  const cell = this.getters.getEvaluatedCell(position);
35138
35158
  const showFormula = this.getters.shouldShowFormulas();
35139
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
35159
+ const { x, y, width, height } = this.getters.getRect(zone);
35140
35160
  const { verticalAlign } = this.getters.getCellStyle(position);
35141
35161
  const box = {
35142
35162
  x,
@@ -35251,12 +35271,16 @@ class GridRenderer {
35251
35271
  }
35252
35272
  return box;
35253
35273
  }
35254
- getGridBoxes() {
35274
+ getGridBoxes(zone) {
35255
35275
  const boxes = [];
35256
- const visibleCols = this.getters.getSheetViewVisibleCols();
35276
+ const visibleCols = this.getters
35277
+ .getSheetViewVisibleCols()
35278
+ .filter((col) => col >= zone.left && col <= zone.right);
35257
35279
  const left = visibleCols[0];
35258
35280
  const right = visibleCols[visibleCols.length - 1];
35259
- const visibleRows = this.getters.getSheetViewVisibleRows();
35281
+ const visibleRows = this.getters
35282
+ .getSheetViewVisibleRows()
35283
+ .filter((row) => row >= zone.top && row <= zone.bottom);
35260
35284
  const top = visibleRows[0];
35261
35285
  const bottom = visibleRows[visibleRows.length - 1];
35262
35286
  const viewport = { left, right, top, bottom };
@@ -51441,14 +51465,12 @@ class SheetUIPlugin extends UIPlugin {
51441
51465
  }
51442
51466
  break;
51443
51467
  case "AUTORESIZE_ROWS":
51444
- for (let row of cmd.rows) {
51445
- this.dispatch("RESIZE_COLUMNS_ROWS", {
51446
- elements: [row],
51447
- dimension: "ROW",
51448
- size: null,
51449
- sheetId: cmd.sheetId,
51450
- });
51451
- }
51468
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
51469
+ elements: cmd.rows,
51470
+ dimension: "ROW",
51471
+ size: null,
51472
+ sheetId: cmd.sheetId,
51473
+ });
51452
51474
  break;
51453
51475
  }
51454
51476
  }
@@ -53647,8 +53669,12 @@ class GridSelectionPlugin extends UIPlugin {
53647
53669
  },
53648
53670
  ];
53649
53671
  handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
53672
+ const selection = pasteTarget[0];
53673
+ const col = selection.left;
53674
+ const row = selection.top;
53675
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
53650
53676
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
53651
- let currentIndex = cmd.base;
53677
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
53652
53678
  for (const element of toRemove) {
53653
53679
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
53654
53680
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -53927,22 +53953,33 @@ class InternalViewport {
53927
53953
  }
53928
53954
  /**
53929
53955
  *
53930
- * @param zone
53931
- * @returns Computes the absolute coordinate of a given zone inside the viewport
53956
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
53957
+ *
53932
53958
  */
53933
- getRect(zone) {
53959
+ getVisibleRect(zone) {
53934
53960
  const targetZone = intersection(zone, this);
53935
53961
  if (targetZone) {
53936
53962
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
53937
53963
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
53938
53964
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
53939
53965
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
53940
- return {
53941
- x,
53942
- y,
53943
- width,
53944
- height,
53945
- };
53966
+ return { x, y, width, height };
53967
+ }
53968
+ return undefined;
53969
+ }
53970
+ /**
53971
+ *
53972
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
53973
+ *
53974
+ */
53975
+ getFullRect(zone) {
53976
+ const targetZone = intersection(zone, this);
53977
+ if (targetZone) {
53978
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
53979
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
53980
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
53981
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
53982
+ return { x, y, width, height };
53946
53983
  }
53947
53984
  return undefined;
53948
53985
  }
@@ -54112,6 +54149,8 @@ class SheetViewPlugin extends UIPlugin {
54112
54149
  "isPositionVisible",
54113
54150
  "getColDimensionsInViewport",
54114
54151
  "getRowDimensionsInViewport",
54152
+ "getAllActiveViewportsZones",
54153
+ "getRect",
54115
54154
  ];
54116
54155
  viewports = {};
54117
54156
  /**
@@ -54499,16 +54538,27 @@ class SheetViewPlugin extends UIPlugin {
54499
54538
  getVisibleRectWithoutHeaders(zone) {
54500
54539
  const sheetId = this.getters.getActiveSheetId();
54501
54540
  const viewportRects = this.getSubViewports(sheetId)
54502
- .map((viewport) => viewport.getRect(zone))
54541
+ .map((viewport) => viewport.getVisibleRect(zone))
54503
54542
  .filter(isDefined$1);
54504
54543
  if (viewportRects.length === 0) {
54505
54544
  return { x: 0, y: 0, width: 0, height: 0 };
54506
54545
  }
54507
- const x = Math.min(...viewportRects.map((rect) => rect.x));
54508
- const y = Math.min(...viewportRects.map((rect) => rect.y));
54509
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54510
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54511
- return { x, y, width, height };
54546
+ return this.recomposeRect(viewportRects);
54547
+ }
54548
+ /**
54549
+ * Computes the actual size and position (:Rect) of the zone on the canvas
54550
+ * regardless of the viewport dimensions.
54551
+ */
54552
+ getRect(zone) {
54553
+ const sheetId = this.getters.getActiveSheetId();
54554
+ const viewportRects = this.getSubViewports(sheetId)
54555
+ .map((viewport) => viewport.getFullRect(zone))
54556
+ .filter(isDefined$1);
54557
+ if (viewportRects.length === 0) {
54558
+ return { x: 0, y: 0, width: 0, height: 0 };
54559
+ }
54560
+ const rect = this.recomposeRect(viewportRects);
54561
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
54512
54562
  }
54513
54563
  /**
54514
54564
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -54552,6 +54602,10 @@ class SheetViewPlugin extends UIPlugin {
54552
54602
  end: start + (isRowHidden ? 0 : size),
54553
54603
  };
54554
54604
  }
54605
+ getAllActiveViewportsZones() {
54606
+ const sheetId = this.getters.getActiveSheetId();
54607
+ return this.getSubViewports(sheetId);
54608
+ }
54555
54609
  // ---------------------------------------------------------------------------
54556
54610
  // Private
54557
54611
  // ---------------------------------------------------------------------------
@@ -54736,6 +54790,13 @@ class SheetViewPlugin extends UIPlugin {
54736
54790
  const height = this.sheetViewHeight + this.gridOffsetY;
54737
54791
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
54738
54792
  }
54793
+ recomposeRect(viewportRects) {
54794
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
54795
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
54796
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54797
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54798
+ return { x, y, width, height };
54799
+ }
54739
54800
  }
54740
54801
 
54741
54802
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -61073,6 +61134,6 @@ exports.tokenColors = tokenColors;
61073
61134
  exports.tokenize = tokenize;
61074
61135
 
61075
61136
 
61076
- __info__.version = "17.2.32";
61077
- __info__.date = "2025-01-15T08:03:19.290Z";
61078
- __info__.hash = "e12286d";
61137
+ __info__.version = "17.2.34";
61138
+ __info__.date = "2025-01-31T07:58:03.953Z";
61139
+ __info__.hash = "0bffee9";
@@ -4342,10 +4342,16 @@ declare class InternalViewport {
4342
4342
  adjustViewportZone(): void;
4343
4343
  /**
4344
4344
  *
4345
- * @param zone
4346
- * @returns Computes the absolute coordinate of a given zone inside the viewport
4345
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
4346
+ *
4347
4347
  */
4348
- getRect(zone: Zone): Rect | undefined;
4348
+ getVisibleRect(zone: Zone): Rect | undefined;
4349
+ /**
4350
+ *
4351
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
4352
+ *
4353
+ */
4354
+ getFullRect(zone: Zone): Rect | undefined;
4349
4355
  isVisible(col: HeaderIndex, row: HeaderIndex): boolean;
4350
4356
  private searchHeaderIndex;
4351
4357
  private setViewportOffsetX;
@@ -4414,7 +4420,7 @@ type SheetViewports = {
4414
4420
  *
4415
4421
  */
4416
4422
  declare class SheetViewPlugin extends UIPlugin {
4417
- static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getVisibleRectWithoutHeaders", "getVisibleCellPositions", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio", "isPositionVisible", "getColDimensionsInViewport", "getRowDimensionsInViewport"];
4423
+ static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getVisibleRectWithoutHeaders", "getVisibleCellPositions", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio", "isPositionVisible", "getColDimensionsInViewport", "getRowDimensionsInViewport", "getAllActiveViewportsZones", "getRect"];
4418
4424
  readonly viewports: Record<UID, SheetViewports | undefined>;
4419
4425
  /**
4420
4426
  * The viewport dimensions are usually set by one of the components
@@ -4485,6 +4491,11 @@ declare class SheetViewPlugin extends UIPlugin {
4485
4491
  * Computes the coordinates and size to draw the zone without taking the grid offset into account
4486
4492
  */
4487
4493
  getVisibleRectWithoutHeaders(zone: Zone): Rect;
4494
+ /**
4495
+ * Computes the actual size and position (:Rect) of the zone on the canvas
4496
+ * regardless of the viewport dimensions.
4497
+ */
4498
+ getRect(zone: Zone): Rect;
4488
4499
  /**
4489
4500
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
4490
4501
  * It corresponds to the summed dimensions of the visible cols/rows (in x/y respectively)
@@ -4501,6 +4512,7 @@ declare class SheetViewPlugin extends UIPlugin {
4501
4512
  * of the current viewport
4502
4513
  */
4503
4514
  getRowDimensionsInViewport(sheetId: UID, row: HeaderIndex): HeaderDimensions;
4515
+ getAllActiveViewportsZones(): Zone[];
4504
4516
  private ensureMainViewportExist;
4505
4517
  private getSubViewports;
4506
4518
  private checkPositiveDimension;
@@ -4531,6 +4543,7 @@ declare class SheetViewPlugin extends UIPlugin {
4531
4543
  xRatio: number;
4532
4544
  yRatio: number;
4533
4545
  };
4546
+ private recomposeRect;
4534
4547
  }
4535
4548
 
4536
4549
  /**