@odoo/o-spreadsheet 17.0.45 → 17.0.47

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.45
6
- * @date 2025-01-14T11:30:44.730Z
7
- * @hash 94f8ef9
5
+ * @version 17.0.47
6
+ * @date 2025-01-31T07:56:50.980Z
7
+ * @hash a22bce2
8
8
  */
9
9
 
10
10
  'use strict';
@@ -1847,11 +1847,11 @@ const getInvaluableSymbolsRegexp = memoize(function getInvaluableSymbolsRegexp(l
1847
1847
  * number from the point of view of the isNumber function.
1848
1848
  */
1849
1849
  function parseNumber(str, locale) {
1850
+ // remove invaluable characters
1851
+ str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1850
1852
  if (locale.decimalSeparator !== ".") {
1851
1853
  str = str.replace(locale.decimalSeparator, ".");
1852
1854
  }
1853
- // remove invaluable characters
1854
- str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1855
1855
  let n = Number(str);
1856
1856
  if (isNaN(n) && str.includes("%")) {
1857
1857
  n = Number(str.split("%")[0]);
@@ -2697,15 +2697,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2697
2697
  let currentIndex;
2698
2698
  let currentVal;
2699
2699
  let currentType;
2700
+ const getValue = sortOrder === "desc"
2701
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2702
+ : (i) => normalizeValue(getValueInData(data, i));
2700
2703
  while (indexRight - indexLeft >= 0) {
2701
2704
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2702
2705
  currentIndex = indexMedian;
2703
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2706
+ currentVal = getValue(currentIndex);
2704
2707
  currentType = typeof currentVal;
2705
2708
  // 1 - linear search to find value with the same type
2706
2709
  while (indexLeft < currentIndex && targetType !== currentType) {
2707
2710
  currentIndex--;
2708
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2711
+ currentVal = getValue(currentIndex);
2709
2712
  currentType = typeof currentVal;
2710
2713
  }
2711
2714
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2721,8 +2724,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2721
2724
  if (matchVal === undefined ||
2722
2725
  matchVal === null ||
2723
2726
  matchVal < currentVal ||
2724
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2725
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2727
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2726
2728
  matchVal = currentVal;
2727
2729
  matchValIndex = currentIndex;
2728
2730
  }
@@ -2730,15 +2732,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2730
2732
  else if (mode === "nextGreater" && currentVal >= _target) {
2731
2733
  if (matchVal === undefined ||
2732
2734
  matchVal > currentVal ||
2733
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2734
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2735
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2735
2736
  matchVal = currentVal;
2736
2737
  matchValIndex = currentIndex;
2737
2738
  }
2738
2739
  }
2739
2740
  // 3 - give new indexes for the Binary search
2740
- if ((sortOrder === "asc" && currentVal > _target) ||
2741
- (sortOrder === "desc" && currentVal <= _target)) {
2741
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2742
2742
  indexRight = currentIndex - 1;
2743
2743
  }
2744
2744
  else {
@@ -2746,7 +2746,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2746
2746
  }
2747
2747
  }
2748
2748
  // note that valMinIndex could be 0
2749
- return matchValIndex !== undefined ? matchValIndex : -1;
2749
+ if (matchValIndex === undefined) {
2750
+ return -1;
2751
+ }
2752
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2750
2753
  }
2751
2754
  /**
2752
2755
  * Perform a linear search and return the index of the match.
@@ -6940,6 +6943,10 @@ class Popover extends owl.Component {
6940
6943
  this.currentDisplayValue = newDisplay;
6941
6944
  if (!anchor)
6942
6945
  return;
6946
+ el.style.top = "";
6947
+ el.style.left = "";
6948
+ el.style["max-height"] = "";
6949
+ el.style["max-width"] = "";
6943
6950
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6944
6951
  let elDims = {
6945
6952
  width: el.getBoundingClientRect().width,
@@ -27454,7 +27461,7 @@ class GridComposer extends owl.Component {
27454
27461
  return;
27455
27462
  }
27456
27463
  const sheetId = this.env.model.getters.getActiveSheetId();
27457
- const zone = this.env.model.getters.getSelectedZone();
27464
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
27458
27465
  const rect = this.env.model.getters.getVisibleRect(zone);
27459
27466
  if (!deepEquals(rect, this.rect) ||
27460
27467
  sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
@@ -46261,13 +46268,23 @@ class RendererPlugin extends UIPlugin {
46261
46268
  drawGrid(renderingContext, layer) {
46262
46269
  switch (layer) {
46263
46270
  case 0 /* LAYERS.Background */:
46264
- this.boxes = this.getGridBoxes();
46265
- this.drawBackground(renderingContext);
46266
- this.drawOverflowingCellBackground(renderingContext);
46267
- this.drawCellBackground(renderingContext);
46268
- this.drawBorders(renderingContext);
46269
- this.drawTexts(renderingContext);
46270
- this.drawIcon(renderingContext);
46271
+ this.drawGlobalBackground(renderingContext);
46272
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
46273
+ const { ctx } = renderingContext;
46274
+ ctx.save();
46275
+ ctx.beginPath();
46276
+ const rect = this.getters.getVisibleRect(zone);
46277
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
46278
+ ctx.clip();
46279
+ this.boxes = this.getGridBoxes(zone);
46280
+ this.drawBackground(renderingContext);
46281
+ this.drawOverflowingCellBackground(renderingContext);
46282
+ this.drawCellBackground(renderingContext);
46283
+ this.drawBorders(renderingContext);
46284
+ this.drawTexts(renderingContext);
46285
+ this.drawIcon(renderingContext);
46286
+ ctx.restore();
46287
+ }
46271
46288
  this.drawFrozenPanes(renderingContext);
46272
46289
  break;
46273
46290
  case 7 /* LAYERS.Headers */:
@@ -46278,12 +46295,15 @@ class RendererPlugin extends UIPlugin {
46278
46295
  break;
46279
46296
  }
46280
46297
  }
46281
- drawBackground(renderingContext) {
46282
- const { ctx, thinLineWidth } = renderingContext;
46298
+ drawGlobalBackground(renderingContext) {
46299
+ const { ctx } = renderingContext;
46283
46300
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
46284
46301
  // white background
46285
46302
  ctx.fillStyle = "#ffffff";
46286
46303
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
46304
+ }
46305
+ drawBackground(renderingContext) {
46306
+ const { ctx, thinLineWidth } = renderingContext;
46287
46307
  const areGridLinesVisible = !this.getters.isDashboard() &&
46288
46308
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
46289
46309
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -46714,7 +46734,7 @@ class RendererPlugin extends UIPlugin {
46714
46734
  const position = { sheetId, col, row };
46715
46735
  const cell = this.getters.getEvaluatedCell(position);
46716
46736
  const showFormula = this.getters.shouldShowFormulas();
46717
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
46737
+ const { x, y, width, height } = this.getters.getRect(zone);
46718
46738
  const { verticalAlign } = this.getters.getCellStyle(position);
46719
46739
  const box = {
46720
46740
  x,
@@ -46829,12 +46849,16 @@ class RendererPlugin extends UIPlugin {
46829
46849
  }
46830
46850
  return box;
46831
46851
  }
46832
- getGridBoxes() {
46852
+ getGridBoxes(zone) {
46833
46853
  const boxes = [];
46834
- const visibleCols = this.getters.getSheetViewVisibleCols();
46854
+ const visibleCols = this.getters
46855
+ .getSheetViewVisibleCols()
46856
+ .filter((col) => col >= zone.left && col <= zone.right);
46835
46857
  const left = visibleCols[0];
46836
46858
  const right = visibleCols[visibleCols.length - 1];
46837
- const visibleRows = this.getters.getSheetViewVisibleRows();
46859
+ const visibleRows = this.getters
46860
+ .getSheetViewVisibleRows()
46861
+ .filter((row) => row >= zone.top && row <= zone.bottom);
46838
46862
  const top = visibleRows[0];
46839
46863
  const bottom = visibleRows[visibleRows.length - 1];
46840
46864
  const viewport = { left, right, top, bottom };
@@ -47627,14 +47651,12 @@ class SheetUIPlugin extends UIPlugin {
47627
47651
  }
47628
47652
  break;
47629
47653
  case "AUTORESIZE_ROWS":
47630
- for (let row of cmd.rows) {
47631
- this.dispatch("RESIZE_COLUMNS_ROWS", {
47632
- elements: [row],
47633
- dimension: "ROW",
47634
- size: null,
47635
- sheetId: cmd.sheetId,
47636
- });
47637
- }
47654
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
47655
+ elements: cmd.rows,
47656
+ dimension: "ROW",
47657
+ size: null,
47658
+ sheetId: cmd.sheetId,
47659
+ });
47638
47660
  break;
47639
47661
  }
47640
47662
  }
@@ -50361,7 +50383,7 @@ class GridSelectionPlugin extends UIPlugin {
50361
50383
  ];
50362
50384
  state.paste(pasteTarget, { selectTarget: true });
50363
50385
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50364
- let currentIndex = cmd.base;
50386
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50365
50387
  for (const element of toRemove) {
50366
50388
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50367
50389
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -50652,7 +50674,7 @@ class InternalViewport {
50652
50674
  * @param zone
50653
50675
  * @returns Computes the absolute coordinate of a given zone inside the viewport
50654
50676
  */
50655
- getRect(zone) {
50677
+ getVisibleRect(zone) {
50656
50678
  const targetZone = intersection(zone, this.zone);
50657
50679
  if (targetZone) {
50658
50680
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -50660,12 +50682,20 @@ class InternalViewport {
50660
50682
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
50661
50683
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
50662
50684
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
50663
- return {
50664
- x,
50665
- y,
50666
- width,
50667
- height,
50668
- };
50685
+ return { x, y, width, height };
50686
+ }
50687
+ else {
50688
+ return undefined;
50689
+ }
50690
+ }
50691
+ getFullRect(zone) {
50692
+ const targetZone = intersection(zone, this.zone);
50693
+ if (targetZone) {
50694
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
50695
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
50696
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
50697
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
50698
+ return { x, y, width, height };
50669
50699
  }
50670
50700
  else {
50671
50701
  return undefined;
@@ -50849,6 +50879,8 @@ class SheetViewPlugin extends UIPlugin {
50849
50879
  "getSheetViewVisibleRows",
50850
50880
  "getFrozenSheetViewRatio",
50851
50881
  "isPositionVisible",
50882
+ "getAllActiveViewportsZones",
50883
+ "getRect",
50852
50884
  ];
50853
50885
  viewports = {};
50854
50886
  /**
@@ -51236,16 +51268,27 @@ class SheetViewPlugin extends UIPlugin {
51236
51268
  getVisibleRectWithoutHeaders(zone) {
51237
51269
  const sheetId = this.getters.getActiveSheetId();
51238
51270
  const viewportRects = this.getSubViewports(sheetId)
51239
- .map((viewport) => viewport.getRect(zone))
51271
+ .map((viewport) => viewport.getVisibleRect(zone))
51240
51272
  .filter(isDefined$1);
51241
51273
  if (viewportRects.length === 0) {
51242
51274
  return { x: 0, y: 0, width: 0, height: 0 };
51243
51275
  }
51244
- const x = Math.min(...viewportRects.map((rect) => rect.x));
51245
- const y = Math.min(...viewportRects.map((rect) => rect.y));
51246
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51247
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51248
- return { x, y, width, height };
51276
+ return this.recomposeRect(viewportRects);
51277
+ }
51278
+ /**
51279
+ * Computes the actual size and position (:Rect) of the zone on the canvas
51280
+ * regardless of the viewport dimensions.
51281
+ */
51282
+ getRect(zone) {
51283
+ const sheetId = this.getters.getActiveSheetId();
51284
+ const viewportRects = this.getSubViewports(sheetId)
51285
+ .map((viewport) => viewport.getFullRect(zone))
51286
+ .filter(isDefined$1);
51287
+ if (viewportRects.length === 0) {
51288
+ return { x: 0, y: 0, width: 0, height: 0 };
51289
+ }
51290
+ const rect = this.recomposeRect(viewportRects);
51291
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
51249
51292
  }
51250
51293
  /**
51251
51294
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -51259,6 +51302,10 @@ class SheetViewPlugin extends UIPlugin {
51259
51302
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
51260
51303
  return { x, y };
51261
51304
  }
51305
+ getAllActiveViewportsZones() {
51306
+ const sheetId = this.getters.getActiveSheetId();
51307
+ return this.getSubViewports(sheetId);
51308
+ }
51262
51309
  // ---------------------------------------------------------------------------
51263
51310
  // Private
51264
51311
  // ---------------------------------------------------------------------------
@@ -51443,6 +51490,13 @@ class SheetViewPlugin extends UIPlugin {
51443
51490
  const height = this.sheetViewHeight + this.gridOffsetY;
51444
51491
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
51445
51492
  }
51493
+ recomposeRect(viewportRects) {
51494
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
51495
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
51496
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51497
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51498
+ return { x, y, width, height };
51499
+ }
51446
51500
  }
51447
51501
 
51448
51502
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -57750,6 +57804,6 @@ exports.setTranslationMethod = setTranslationMethod;
57750
57804
  exports.tokenize = tokenize;
57751
57805
 
57752
57806
 
57753
- __info__.version = "17.0.45";
57754
- __info__.date = "2025-01-14T11:30:44.730Z";
57755
- __info__.hash = "94f8ef9";
57807
+ __info__.version = "17.0.47";
57808
+ __info__.date = "2025-01-31T07:56:50.980Z";
57809
+ __info__.hash = "a22bce2";
@@ -4610,6 +4610,7 @@ declare class RendererPlugin extends UIPlugin {
4610
4610
  */
4611
4611
  private getHeaderOffset;
4612
4612
  drawGrid(renderingContext: GridRenderingContext, layer: LAYERS): void;
4613
+ private drawGlobalBackground;
4613
4614
  private drawBackground;
4614
4615
  private drawCellBackground;
4615
4616
  private drawOverflowingCellBackground;
@@ -5082,7 +5083,8 @@ declare class InternalViewport {
5082
5083
  * @param zone
5083
5084
  * @returns Computes the absolute coordinate of a given zone inside the viewport
5084
5085
  */
5085
- getRect(zone: Zone): Rect | undefined;
5086
+ getVisibleRect(zone: Zone): Rect | undefined;
5087
+ getFullRect(zone: Zone): Rect | undefined;
5086
5088
  isVisible(col: HeaderIndex, row: HeaderIndex): boolean;
5087
5089
  private searchHeaderIndex;
5088
5090
  private get zone();
@@ -5152,7 +5154,7 @@ type SheetViewports = {
5152
5154
  *
5153
5155
  */
5154
5156
  declare class SheetViewPlugin extends UIPlugin {
5155
- static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getVisibleRectWithoutHeaders", "getVisibleCellPositions", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio", "isPositionVisible"];
5157
+ static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getVisibleRectWithoutHeaders", "getVisibleCellPositions", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio", "isPositionVisible", "getAllActiveViewportsZones", "getRect"];
5156
5158
  readonly viewports: Record<UID, SheetViewports | undefined>;
5157
5159
  /**
5158
5160
  * The viewport dimensions are usually set by one of the components
@@ -5223,12 +5225,18 @@ declare class SheetViewPlugin extends UIPlugin {
5223
5225
  * Computes the coordinates and size to draw the zone without taking the grid offset into account
5224
5226
  */
5225
5227
  getVisibleRectWithoutHeaders(zone: Zone): Rect;
5228
+ /**
5229
+ * Computes the actual size and position (:Rect) of the zone on the canvas
5230
+ * regardless of the viewport dimensions.
5231
+ */
5232
+ getRect(zone: Zone): Rect;
5226
5233
  /**
5227
5234
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
5228
5235
  * It corresponds to the summed dimensions of the visible cols/rows (in x/y respectively)
5229
5236
  * situated before the pane divisions.
5230
5237
  */
5231
5238
  getMainViewportCoordinates(): DOMCoordinates;
5239
+ getAllActiveViewportsZones(): Zone[];
5232
5240
  private ensureMainViewportExist;
5233
5241
  private getSubViewports;
5234
5242
  private checkPositiveDimension;
@@ -5259,6 +5267,7 @@ declare class SheetViewPlugin extends UIPlugin {
5259
5267
  xRatio: number;
5260
5268
  yRatio: number;
5261
5269
  };
5270
+ private recomposeRect;
5262
5271
  }
5263
5272
 
5264
5273
  /**