@odoo/o-spreadsheet 16.0.57 → 16.0.59

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.
@@ -11568,15 +11568,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11568
11568
  let currentIndex;
11569
11569
  let currentVal;
11570
11570
  let currentType;
11571
+ const getValue = sortOrder === "desc"
11572
+ ? (i) => getValueInData(data, rangeLength - i - 1)
11573
+ : (i) => getValueInData(data, i);
11571
11574
  while (indexRight - indexLeft >= 0) {
11572
11575
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
11573
11576
  currentIndex = indexMedian;
11574
- currentVal = getValueInData(data, currentIndex);
11577
+ currentVal = getValue(currentIndex);
11575
11578
  currentType = typeof currentVal;
11576
11579
  // 1 - linear search to find value with the same type
11577
11580
  while (indexLeft < currentIndex && targetType !== currentType) {
11578
11581
  currentIndex--;
11579
- currentVal = getValueInData(data, currentIndex);
11582
+ currentVal = getValue(currentIndex);
11580
11583
  currentType = typeof currentVal;
11581
11584
  }
11582
11585
  if (currentType !== targetType || currentVal === undefined) {
@@ -11591,8 +11594,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11591
11594
  else if (mode === "nextSmaller" && currentVal <= target) {
11592
11595
  if (matchVal === undefined ||
11593
11596
  matchVal < currentVal ||
11594
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11595
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11597
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11596
11598
  matchVal = currentVal;
11597
11599
  matchValIndex = currentIndex;
11598
11600
  }
@@ -11600,15 +11602,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11600
11602
  else if (mode === "nextGreater" && currentVal >= target) {
11601
11603
  if (matchVal === undefined ||
11602
11604
  matchVal > currentVal ||
11603
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11604
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11605
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11605
11606
  matchVal = currentVal;
11606
11607
  matchValIndex = currentIndex;
11607
11608
  }
11608
11609
  }
11609
11610
  // 3 - give new indexes for the Binary search
11610
- if ((sortOrder === "asc" && currentVal > target) ||
11611
- (sortOrder === "desc" && currentVal <= target)) {
11611
+ if (currentVal > target || (mode === "strict" && currentVal === target)) {
11612
11612
  indexRight = currentIndex - 1;
11613
11613
  }
11614
11614
  else {
@@ -11616,7 +11616,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11616
11616
  }
11617
11617
  }
11618
11618
  // note that valMinIndex could be 0
11619
- return matchValIndex !== undefined ? matchValIndex : -1;
11619
+ if (matchValIndex === undefined) {
11620
+ return -1;
11621
+ }
11622
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
11620
11623
  }
11621
11624
  /**
11622
11625
  * Perform a linear search and return the index of the match.
@@ -34419,12 +34422,21 @@ class RendererPlugin extends UIPlugin {
34419
34422
  drawGrid(renderingContext, layer) {
34420
34423
  switch (layer) {
34421
34424
  case 0 /* LAYERS.Background */:
34422
- this.boxes = this.getGridBoxes();
34423
34425
  this.drawBackground(renderingContext);
34424
- this.drawCellBackground(renderingContext);
34425
- this.drawBorders(renderingContext);
34426
- this.drawTexts(renderingContext);
34427
- this.drawIcon(renderingContext);
34426
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
34427
+ const { ctx } = renderingContext;
34428
+ ctx.save();
34429
+ ctx.beginPath();
34430
+ const rect = this.getters.getVisibleRect(zone);
34431
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
34432
+ ctx.clip();
34433
+ this.boxes = this.getGridBoxes(zone);
34434
+ this.drawCellBackground(renderingContext);
34435
+ this.drawBorders(renderingContext);
34436
+ this.drawTexts(renderingContext);
34437
+ this.drawIcon(renderingContext);
34438
+ ctx.restore();
34439
+ }
34428
34440
  this.drawFrozenPanes(renderingContext);
34429
34441
  break;
34430
34442
  case 7 /* LAYERS.Headers */:
@@ -34789,7 +34801,7 @@ class RendererPlugin extends UIPlugin {
34789
34801
  const row = zone.top;
34790
34802
  const cell = this.getters.getCell(sheetId, col, row);
34791
34803
  const showFormula = this.getters.shouldShowFormulas();
34792
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
34804
+ const { x, y, width, height } = this.getters.getRect(zone);
34793
34805
  const box = {
34794
34806
  x,
34795
34807
  y,
@@ -34901,12 +34913,16 @@ class RendererPlugin extends UIPlugin {
34901
34913
  }
34902
34914
  return box;
34903
34915
  }
34904
- getGridBoxes() {
34916
+ getGridBoxes(zone) {
34905
34917
  const boxes = [];
34906
- const visibleCols = this.getters.getSheetViewVisibleCols();
34918
+ const visibleCols = this.getters
34919
+ .getSheetViewVisibleCols()
34920
+ .filter((col) => col >= zone.left && col <= zone.right);
34907
34921
  const left = visibleCols[0];
34908
34922
  const right = visibleCols[visibleCols.length - 1];
34909
- const visibleRows = this.getters.getSheetViewVisibleRows();
34923
+ const visibleRows = this.getters
34924
+ .getSheetViewVisibleRows()
34925
+ .filter((row) => row >= zone.top && row <= zone.bottom);
34910
34926
  const top = visibleRows[0];
34911
34927
  const bottom = visibleRows[visibleRows.length - 1];
34912
34928
  const viewport = { left, right, top, bottom };
@@ -35436,7 +35452,7 @@ class GridSelectionPlugin extends UIPlugin {
35436
35452
  ];
35437
35453
  state.paste(pasteTarget, { selectTarget: true });
35438
35454
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
35439
- let currentIndex = cmd.base;
35455
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
35440
35456
  for (const element of toRemove) {
35441
35457
  const size = cmd.dimension === "COL"
35442
35458
  ? this.getters.getColSize(cmd.sheetId, element)
@@ -36943,7 +36959,7 @@ class InternalViewport {
36943
36959
  * @param zone
36944
36960
  * @returns Computes the absolute coordinate of a given zone inside the viewport
36945
36961
  */
36946
- getRect(zone) {
36962
+ getVisibleRect(zone) {
36947
36963
  const targetZone = intersection(zone, this.zone);
36948
36964
  if (targetZone) {
36949
36965
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -36951,12 +36967,20 @@ class InternalViewport {
36951
36967
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
36952
36968
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
36953
36969
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
36954
- return {
36955
- x,
36956
- y,
36957
- width,
36958
- height,
36959
- };
36970
+ return { x, y, width, height };
36971
+ }
36972
+ else {
36973
+ return undefined;
36974
+ }
36975
+ }
36976
+ getFullRect(zone) {
36977
+ const targetZone = intersection(zone, this.zone);
36978
+ if (targetZone) {
36979
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
36980
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
36981
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
36982
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
36983
+ return { x, y, width, height };
36960
36984
  }
36961
36985
  else {
36962
36986
  return undefined;
@@ -37450,21 +37474,26 @@ class SheetViewPlugin extends UIPlugin {
37450
37474
  getVisibleRect(zone) {
37451
37475
  const sheetId = this.getters.getActiveSheetId();
37452
37476
  const viewportRects = this.getSubViewports(sheetId)
37453
- .map((viewport) => viewport.getRect(zone))
37477
+ .map((viewport) => viewport.getVisibleRect(zone))
37454
37478
  .filter(isDefined$1);
37455
37479
  if (viewportRects.length === 0) {
37456
37480
  return { x: 0, y: 0, width: 0, height: 0 };
37457
37481
  }
37458
- const x = Math.min(...viewportRects.map((rect) => rect.x));
37459
- const y = Math.min(...viewportRects.map((rect) => rect.y));
37460
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37461
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37462
- return {
37463
- x: x + this.gridOffsetX,
37464
- y: y + this.gridOffsetY,
37465
- width,
37466
- height,
37467
- };
37482
+ return this.recomposeRect(viewportRects);
37483
+ }
37484
+ /**
37485
+ * Computes the actual size and position (:Rect) of the zone on the canvas
37486
+ * regardless of the viewport dimensions.
37487
+ */
37488
+ getRect(zone) {
37489
+ const sheetId = this.getters.getActiveSheetId();
37490
+ const viewportRects = this.getSubViewports(sheetId)
37491
+ .map((viewport) => viewport.getFullRect(zone))
37492
+ .filter(isDefined$1);
37493
+ if (viewportRects.length === 0) {
37494
+ return { x: 0, y: 0, width: 0, height: 0 };
37495
+ }
37496
+ return this.recomposeRect(viewportRects);
37468
37497
  }
37469
37498
  /**
37470
37499
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -37478,6 +37507,10 @@ class SheetViewPlugin extends UIPlugin {
37478
37507
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
37479
37508
  return { x, y };
37480
37509
  }
37510
+ getAllActiveViewportsZones() {
37511
+ const sheetId = this.getters.getActiveSheetId();
37512
+ return this.getSubViewports(sheetId);
37513
+ }
37481
37514
  // ---------------------------------------------------------------------------
37482
37515
  // Private
37483
37516
  // ---------------------------------------------------------------------------
@@ -37660,6 +37693,18 @@ class SheetViewPlugin extends UIPlugin {
37660
37693
  const height = this.sheetViewHeight + this.gridOffsetY;
37661
37694
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
37662
37695
  }
37696
+ recomposeRect(viewportRects) {
37697
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
37698
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
37699
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37700
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37701
+ return {
37702
+ x: x + this.gridOffsetX,
37703
+ y: y + this.gridOffsetY,
37704
+ width,
37705
+ height,
37706
+ };
37707
+ }
37663
37708
  }
37664
37709
  SheetViewPlugin.getters = [
37665
37710
  "getColIndex",
@@ -37680,6 +37725,8 @@ SheetViewPlugin.getters = [
37680
37725
  "getSheetViewVisibleCols",
37681
37726
  "getSheetViewVisibleRows",
37682
37727
  "getFrozenSheetViewRatio",
37728
+ "getAllActiveViewportsZones",
37729
+ "getRect",
37683
37730
  ];
37684
37731
 
37685
37732
  class SortPlugin extends UIPlugin {
@@ -38035,14 +38082,12 @@ class SheetUIPlugin extends UIPlugin {
38035
38082
  }
38036
38083
  break;
38037
38084
  case "AUTORESIZE_ROWS":
38038
- for (let row of cmd.rows) {
38039
- this.dispatch("RESIZE_COLUMNS_ROWS", {
38040
- elements: [row],
38041
- dimension: "ROW",
38042
- size: null,
38043
- sheetId: cmd.sheetId,
38044
- });
38045
- }
38085
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
38086
+ elements: cmd.rows,
38087
+ dimension: "ROW",
38088
+ size: null,
38089
+ sheetId: cmd.sheetId,
38090
+ });
38046
38091
  break;
38047
38092
  }
38048
38093
  }
@@ -43523,6 +43568,6 @@ exports.setTranslationMethod = setTranslationMethod;
43523
43568
  exports.tokenize = tokenize;
43524
43569
 
43525
43570
 
43526
- __info__.version = '16.0.57';
43527
- __info__.date = '2025-01-14T11:28:51.212Z';
43528
- __info__.hash = '5c7bf6e';
43571
+ __info__.version = '16.0.59';
43572
+ __info__.date = '2025-01-29T06:24:17.486Z';
43573
+ __info__.hash = '0897f45';
@@ -4346,7 +4346,8 @@ declare class InternalViewport {
4346
4346
  * @param zone
4347
4347
  * @returns Computes the absolute coordinate of a given zone inside the viewport
4348
4348
  */
4349
- getRect(zone: Zone): Rect | undefined;
4349
+ getVisibleRect(zone: Zone): Rect | undefined;
4350
+ getFullRect(zone: Zone): Rect | undefined;
4350
4351
  isVisible(col: HeaderIndex, row: HeaderIndex): boolean;
4351
4352
  private searchHeaderIndex;
4352
4353
  private get zone();
@@ -4416,7 +4417,7 @@ type SheetViewports = {
4416
4417
  *
4417
4418
  */
4418
4419
  declare class SheetViewPlugin extends UIPlugin {
4419
- static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio"];
4420
+ static getters: readonly ["getColIndex", "getRowIndex", "getActiveMainViewport", "getSheetViewDimension", "getSheetViewDimensionWithHeaders", "getMainViewportRect", "isVisibleInViewport", "getEdgeScrollCol", "getEdgeScrollRow", "getVisibleFigures", "getVisibleRect", "getColRowOffsetInViewport", "getMainViewportCoordinates", "getActiveSheetScrollInfo", "getActiveSheetDOMScrollInfo", "getSheetViewVisibleCols", "getSheetViewVisibleRows", "getFrozenSheetViewRatio", "getAllActiveViewportsZones", "getRect"];
4420
4421
  readonly viewports: Record<UID, SheetViewports | undefined>;
4421
4422
  /**
4422
4423
  * The viewport dimensions are usually set by one of the components
@@ -4478,12 +4479,18 @@ declare class SheetViewPlugin extends UIPlugin {
4478
4479
  * Computes the coordinates and size to draw the zone on the canvas
4479
4480
  */
4480
4481
  getVisibleRect(zone: Zone): Rect;
4482
+ /**
4483
+ * Computes the actual size and position (:Rect) of the zone on the canvas
4484
+ * regardless of the viewport dimensions.
4485
+ */
4486
+ getRect(zone: Zone): Rect;
4481
4487
  /**
4482
4488
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
4483
4489
  * It corresponds to the summed dimensions of the visible cols/rows (in x/y respectively)
4484
4490
  * situated before the pane divisions.
4485
4491
  */
4486
4492
  getMainViewportCoordinates(): DOMCoordinates;
4493
+ getAllActiveViewportsZones(): Zone[];
4487
4494
  private ensureMainViewportExist;
4488
4495
  private getSubViewports;
4489
4496
  private checkPositiveDimension;
@@ -4514,6 +4521,7 @@ declare class SheetViewPlugin extends UIPlugin {
4514
4521
  xRatio: number;
4515
4522
  yRatio: number;
4516
4523
  };
4524
+ private recomposeRect;
4517
4525
  }
4518
4526
 
4519
4527
  declare class SortPlugin extends UIPlugin {
@@ -11564,15 +11564,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11564
11564
  let currentIndex;
11565
11565
  let currentVal;
11566
11566
  let currentType;
11567
+ const getValue = sortOrder === "desc"
11568
+ ? (i) => getValueInData(data, rangeLength - i - 1)
11569
+ : (i) => getValueInData(data, i);
11567
11570
  while (indexRight - indexLeft >= 0) {
11568
11571
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
11569
11572
  currentIndex = indexMedian;
11570
- currentVal = getValueInData(data, currentIndex);
11573
+ currentVal = getValue(currentIndex);
11571
11574
  currentType = typeof currentVal;
11572
11575
  // 1 - linear search to find value with the same type
11573
11576
  while (indexLeft < currentIndex && targetType !== currentType) {
11574
11577
  currentIndex--;
11575
- currentVal = getValueInData(data, currentIndex);
11578
+ currentVal = getValue(currentIndex);
11576
11579
  currentType = typeof currentVal;
11577
11580
  }
11578
11581
  if (currentType !== targetType || currentVal === undefined) {
@@ -11587,8 +11590,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11587
11590
  else if (mode === "nextSmaller" && currentVal <= target) {
11588
11591
  if (matchVal === undefined ||
11589
11592
  matchVal < currentVal ||
11590
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11591
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11593
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11592
11594
  matchVal = currentVal;
11593
11595
  matchValIndex = currentIndex;
11594
11596
  }
@@ -11596,15 +11598,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11596
11598
  else if (mode === "nextGreater" && currentVal >= target) {
11597
11599
  if (matchVal === undefined ||
11598
11600
  matchVal > currentVal ||
11599
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11600
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11601
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11601
11602
  matchVal = currentVal;
11602
11603
  matchValIndex = currentIndex;
11603
11604
  }
11604
11605
  }
11605
11606
  // 3 - give new indexes for the Binary search
11606
- if ((sortOrder === "asc" && currentVal > target) ||
11607
- (sortOrder === "desc" && currentVal <= target)) {
11607
+ if (currentVal > target || (mode === "strict" && currentVal === target)) {
11608
11608
  indexRight = currentIndex - 1;
11609
11609
  }
11610
11610
  else {
@@ -11612,7 +11612,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
11612
11612
  }
11613
11613
  }
11614
11614
  // note that valMinIndex could be 0
11615
- return matchValIndex !== undefined ? matchValIndex : -1;
11615
+ if (matchValIndex === undefined) {
11616
+ return -1;
11617
+ }
11618
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
11616
11619
  }
11617
11620
  /**
11618
11621
  * Perform a linear search and return the index of the match.
@@ -34415,12 +34418,21 @@ class RendererPlugin extends UIPlugin {
34415
34418
  drawGrid(renderingContext, layer) {
34416
34419
  switch (layer) {
34417
34420
  case 0 /* LAYERS.Background */:
34418
- this.boxes = this.getGridBoxes();
34419
34421
  this.drawBackground(renderingContext);
34420
- this.drawCellBackground(renderingContext);
34421
- this.drawBorders(renderingContext);
34422
- this.drawTexts(renderingContext);
34423
- this.drawIcon(renderingContext);
34422
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
34423
+ const { ctx } = renderingContext;
34424
+ ctx.save();
34425
+ ctx.beginPath();
34426
+ const rect = this.getters.getVisibleRect(zone);
34427
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
34428
+ ctx.clip();
34429
+ this.boxes = this.getGridBoxes(zone);
34430
+ this.drawCellBackground(renderingContext);
34431
+ this.drawBorders(renderingContext);
34432
+ this.drawTexts(renderingContext);
34433
+ this.drawIcon(renderingContext);
34434
+ ctx.restore();
34435
+ }
34424
34436
  this.drawFrozenPanes(renderingContext);
34425
34437
  break;
34426
34438
  case 7 /* LAYERS.Headers */:
@@ -34785,7 +34797,7 @@ class RendererPlugin extends UIPlugin {
34785
34797
  const row = zone.top;
34786
34798
  const cell = this.getters.getCell(sheetId, col, row);
34787
34799
  const showFormula = this.getters.shouldShowFormulas();
34788
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
34800
+ const { x, y, width, height } = this.getters.getRect(zone);
34789
34801
  const box = {
34790
34802
  x,
34791
34803
  y,
@@ -34897,12 +34909,16 @@ class RendererPlugin extends UIPlugin {
34897
34909
  }
34898
34910
  return box;
34899
34911
  }
34900
- getGridBoxes() {
34912
+ getGridBoxes(zone) {
34901
34913
  const boxes = [];
34902
- const visibleCols = this.getters.getSheetViewVisibleCols();
34914
+ const visibleCols = this.getters
34915
+ .getSheetViewVisibleCols()
34916
+ .filter((col) => col >= zone.left && col <= zone.right);
34903
34917
  const left = visibleCols[0];
34904
34918
  const right = visibleCols[visibleCols.length - 1];
34905
- const visibleRows = this.getters.getSheetViewVisibleRows();
34919
+ const visibleRows = this.getters
34920
+ .getSheetViewVisibleRows()
34921
+ .filter((row) => row >= zone.top && row <= zone.bottom);
34906
34922
  const top = visibleRows[0];
34907
34923
  const bottom = visibleRows[visibleRows.length - 1];
34908
34924
  const viewport = { left, right, top, bottom };
@@ -35432,7 +35448,7 @@ class GridSelectionPlugin extends UIPlugin {
35432
35448
  ];
35433
35449
  state.paste(pasteTarget, { selectTarget: true });
35434
35450
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
35435
- let currentIndex = cmd.base;
35451
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
35436
35452
  for (const element of toRemove) {
35437
35453
  const size = cmd.dimension === "COL"
35438
35454
  ? this.getters.getColSize(cmd.sheetId, element)
@@ -36939,7 +36955,7 @@ class InternalViewport {
36939
36955
  * @param zone
36940
36956
  * @returns Computes the absolute coordinate of a given zone inside the viewport
36941
36957
  */
36942
- getRect(zone) {
36958
+ getVisibleRect(zone) {
36943
36959
  const targetZone = intersection(zone, this.zone);
36944
36960
  if (targetZone) {
36945
36961
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -36947,12 +36963,20 @@ class InternalViewport {
36947
36963
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
36948
36964
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
36949
36965
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
36950
- return {
36951
- x,
36952
- y,
36953
- width,
36954
- height,
36955
- };
36966
+ return { x, y, width, height };
36967
+ }
36968
+ else {
36969
+ return undefined;
36970
+ }
36971
+ }
36972
+ getFullRect(zone) {
36973
+ const targetZone = intersection(zone, this.zone);
36974
+ if (targetZone) {
36975
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
36976
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
36977
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
36978
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
36979
+ return { x, y, width, height };
36956
36980
  }
36957
36981
  else {
36958
36982
  return undefined;
@@ -37446,21 +37470,26 @@ class SheetViewPlugin extends UIPlugin {
37446
37470
  getVisibleRect(zone) {
37447
37471
  const sheetId = this.getters.getActiveSheetId();
37448
37472
  const viewportRects = this.getSubViewports(sheetId)
37449
- .map((viewport) => viewport.getRect(zone))
37473
+ .map((viewport) => viewport.getVisibleRect(zone))
37450
37474
  .filter(isDefined$1);
37451
37475
  if (viewportRects.length === 0) {
37452
37476
  return { x: 0, y: 0, width: 0, height: 0 };
37453
37477
  }
37454
- const x = Math.min(...viewportRects.map((rect) => rect.x));
37455
- const y = Math.min(...viewportRects.map((rect) => rect.y));
37456
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37457
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37458
- return {
37459
- x: x + this.gridOffsetX,
37460
- y: y + this.gridOffsetY,
37461
- width,
37462
- height,
37463
- };
37478
+ return this.recomposeRect(viewportRects);
37479
+ }
37480
+ /**
37481
+ * Computes the actual size and position (:Rect) of the zone on the canvas
37482
+ * regardless of the viewport dimensions.
37483
+ */
37484
+ getRect(zone) {
37485
+ const sheetId = this.getters.getActiveSheetId();
37486
+ const viewportRects = this.getSubViewports(sheetId)
37487
+ .map((viewport) => viewport.getFullRect(zone))
37488
+ .filter(isDefined$1);
37489
+ if (viewportRects.length === 0) {
37490
+ return { x: 0, y: 0, width: 0, height: 0 };
37491
+ }
37492
+ return this.recomposeRect(viewportRects);
37464
37493
  }
37465
37494
  /**
37466
37495
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -37474,6 +37503,10 @@ class SheetViewPlugin extends UIPlugin {
37474
37503
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
37475
37504
  return { x, y };
37476
37505
  }
37506
+ getAllActiveViewportsZones() {
37507
+ const sheetId = this.getters.getActiveSheetId();
37508
+ return this.getSubViewports(sheetId);
37509
+ }
37477
37510
  // ---------------------------------------------------------------------------
37478
37511
  // Private
37479
37512
  // ---------------------------------------------------------------------------
@@ -37656,6 +37689,18 @@ class SheetViewPlugin extends UIPlugin {
37656
37689
  const height = this.sheetViewHeight + this.gridOffsetY;
37657
37690
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
37658
37691
  }
37692
+ recomposeRect(viewportRects) {
37693
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
37694
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
37695
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37696
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37697
+ return {
37698
+ x: x + this.gridOffsetX,
37699
+ y: y + this.gridOffsetY,
37700
+ width,
37701
+ height,
37702
+ };
37703
+ }
37659
37704
  }
37660
37705
  SheetViewPlugin.getters = [
37661
37706
  "getColIndex",
@@ -37676,6 +37721,8 @@ SheetViewPlugin.getters = [
37676
37721
  "getSheetViewVisibleCols",
37677
37722
  "getSheetViewVisibleRows",
37678
37723
  "getFrozenSheetViewRatio",
37724
+ "getAllActiveViewportsZones",
37725
+ "getRect",
37679
37726
  ];
37680
37727
 
37681
37728
  class SortPlugin extends UIPlugin {
@@ -38031,14 +38078,12 @@ class SheetUIPlugin extends UIPlugin {
38031
38078
  }
38032
38079
  break;
38033
38080
  case "AUTORESIZE_ROWS":
38034
- for (let row of cmd.rows) {
38035
- this.dispatch("RESIZE_COLUMNS_ROWS", {
38036
- elements: [row],
38037
- dimension: "ROW",
38038
- size: null,
38039
- sheetId: cmd.sheetId,
38040
- });
38041
- }
38081
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
38082
+ elements: cmd.rows,
38083
+ dimension: "ROW",
38084
+ size: null,
38085
+ sheetId: cmd.sheetId,
38086
+ });
38042
38087
  break;
38043
38088
  }
38044
38089
  }
@@ -43491,6 +43536,6 @@ function addFunction(functionName, functionDescription) {
43491
43536
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43492
43537
 
43493
43538
 
43494
- __info__.version = '16.0.57';
43495
- __info__.date = '2025-01-14T11:28:51.212Z';
43496
- __info__.hash = '5c7bf6e';
43539
+ __info__.version = '16.0.59';
43540
+ __info__.date = '2025-01-29T06:24:17.486Z';
43541
+ __info__.hash = '0897f45';