@odoo/o-spreadsheet 17.4.17 → 17.4.19

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.4.17
6
- * @date 2025-01-14T11:34:44.930Z
7
- * @hash fd2a7ab
5
+ * @version 17.4.19
6
+ * @date 2025-01-27T10:04:10.249Z
7
+ * @hash f2a7840
8
8
  */
9
9
 
10
10
  'use strict';
@@ -3015,15 +3015,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
3015
3015
  let currentIndex;
3016
3016
  let currentVal;
3017
3017
  let currentType;
3018
+ const getValue = sortOrder === "desc"
3019
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
3020
+ : (i) => normalizeValue(getValueInData(data, i));
3018
3021
  while (indexRight - indexLeft >= 0) {
3019
3022
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
3020
3023
  currentIndex = indexMedian;
3021
- currentVal = normalizeValue(getValueInData(data, currentIndex));
3024
+ currentVal = getValue(currentIndex);
3022
3025
  currentType = typeof currentVal;
3023
3026
  // 1 - linear search to find value with the same type
3024
3027
  while (indexLeft < currentIndex && targetType !== currentType) {
3025
3028
  currentIndex--;
3026
- currentVal = normalizeValue(getValueInData(data, currentIndex));
3029
+ currentVal = getValue(currentIndex);
3027
3030
  currentType = typeof currentVal;
3028
3031
  }
3029
3032
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -3039,8 +3042,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
3039
3042
  if (matchVal === undefined ||
3040
3043
  matchVal === null ||
3041
3044
  matchVal < currentVal ||
3042
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
3043
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
3045
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
3044
3046
  matchVal = currentVal;
3045
3047
  matchValIndex = currentIndex;
3046
3048
  }
@@ -3048,15 +3050,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
3048
3050
  else if (mode === "nextGreater" && currentVal >= _target) {
3049
3051
  if (matchVal === undefined ||
3050
3052
  matchVal > currentVal ||
3051
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
3052
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
3053
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
3053
3054
  matchVal = currentVal;
3054
3055
  matchValIndex = currentIndex;
3055
3056
  }
3056
3057
  }
3057
3058
  // 3 - give new indexes for the Binary search
3058
- if ((sortOrder === "asc" && currentVal > _target) ||
3059
- (sortOrder === "desc" && currentVal <= _target)) {
3059
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
3060
3060
  indexRight = currentIndex - 1;
3061
3061
  }
3062
3062
  else {
@@ -3064,7 +3064,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
3064
3064
  }
3065
3065
  }
3066
3066
  // note that valMinIndex could be 0
3067
- return matchValIndex !== undefined ? matchValIndex : -1;
3067
+ if (matchValIndex === undefined) {
3068
+ return -1;
3069
+ }
3070
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
3068
3071
  }
3069
3072
  /**
3070
3073
  * Perform a linear search and return the index of the match.
@@ -26459,6 +26462,10 @@ class Popover extends owl.Component {
26459
26462
  this.currentDisplayValue = newDisplay;
26460
26463
  if (!anchor)
26461
26464
  return;
26465
+ el.style.top = "";
26466
+ el.style.left = "";
26467
+ el.style["max-height"] = "";
26468
+ el.style["max-width"] = "";
26462
26469
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
26463
26470
  let elDims = {
26464
26471
  width: el.getBoundingClientRect().width,
@@ -39451,7 +39458,7 @@ class GridComposer extends owl.Component {
39451
39458
  return;
39452
39459
  }
39453
39460
  const sheetId = this.env.model.getters.getActiveSheetId();
39454
- const zone = this.env.model.getters.getSelectedZone();
39461
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
39455
39462
  const rect = this.env.model.getters.getVisibleRect(zone);
39456
39463
  if (!deepEquals(rect, this.rect) || sheetId !== this.composerStore.currentEditedCell.sheetId) {
39457
39464
  this.isCellReferenceVisible = true;
@@ -41206,13 +41213,23 @@ class GridRenderer {
41206
41213
  drawLayer(renderingContext, layer) {
41207
41214
  switch (layer) {
41208
41215
  case "Background":
41209
- const boxes = this.getGridBoxes();
41210
- this.drawBackground(renderingContext, boxes);
41211
- this.drawOverflowingCellBackground(renderingContext, boxes);
41212
- this.drawCellBackground(renderingContext, boxes);
41213
- this.drawBorders(renderingContext, boxes);
41214
- this.drawTexts(renderingContext, boxes);
41215
- this.drawIcon(renderingContext, boxes);
41216
+ this.drawGlobalBackground(renderingContext);
41217
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
41218
+ const { ctx } = renderingContext;
41219
+ ctx.save();
41220
+ ctx.beginPath();
41221
+ const rect = this.getters.getVisibleRect(zone);
41222
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
41223
+ ctx.clip();
41224
+ const boxes = this.getGridBoxes(zone);
41225
+ this.drawBackground(renderingContext, boxes);
41226
+ this.drawOverflowingCellBackground(renderingContext, boxes);
41227
+ this.drawCellBackground(renderingContext, boxes);
41228
+ this.drawBorders(renderingContext, boxes);
41229
+ this.drawTexts(renderingContext, boxes);
41230
+ this.drawIcon(renderingContext, boxes);
41231
+ ctx.restore();
41232
+ }
41216
41233
  this.drawFrozenPanes(renderingContext);
41217
41234
  break;
41218
41235
  case "Headers":
@@ -41223,12 +41240,15 @@ class GridRenderer {
41223
41240
  break;
41224
41241
  }
41225
41242
  }
41226
- drawBackground(renderingContext, boxes) {
41227
- const { ctx, thinLineWidth } = renderingContext;
41243
+ drawGlobalBackground(renderingContext) {
41244
+ const { ctx } = renderingContext;
41228
41245
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
41229
41246
  // white background
41230
41247
  ctx.fillStyle = "#ffffff";
41231
41248
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
41249
+ }
41250
+ drawBackground(renderingContext, boxes) {
41251
+ const { ctx, thinLineWidth } = renderingContext;
41232
41252
  const areGridLinesVisible = !this.getters.isDashboard() &&
41233
41253
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
41234
41254
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -41653,7 +41673,7 @@ class GridRenderer {
41653
41673
  const position = { sheetId, col, row };
41654
41674
  const cell = this.getters.getEvaluatedCell(position);
41655
41675
  const showFormula = this.getters.shouldShowFormulas();
41656
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
41676
+ const { x, y, width, height } = this.getters.getRect(zone);
41657
41677
  const { verticalAlign } = this.getters.getCellStyle(position);
41658
41678
  const box = {
41659
41679
  x,
@@ -41769,12 +41789,16 @@ class GridRenderer {
41769
41789
  }
41770
41790
  return box;
41771
41791
  }
41772
- getGridBoxes() {
41792
+ getGridBoxes(zone) {
41773
41793
  const boxes = [];
41774
- const visibleCols = this.getters.getSheetViewVisibleCols();
41794
+ const visibleCols = this.getters
41795
+ .getSheetViewVisibleCols()
41796
+ .filter((col) => col >= zone.left && col <= zone.right);
41775
41797
  const left = visibleCols[0];
41776
41798
  const right = visibleCols[visibleCols.length - 1];
41777
- const visibleRows = this.getters.getSheetViewVisibleRows();
41799
+ const visibleRows = this.getters
41800
+ .getSheetViewVisibleRows()
41801
+ .filter((row) => row >= zone.top && row <= zone.bottom);
41778
41802
  const top = visibleRows[0];
41779
41803
  const bottom = visibleRows[visibleRows.length - 1];
41780
41804
  const viewport = { left, right, top, bottom };
@@ -57578,9 +57602,6 @@ class Session extends EventBus {
57578
57602
  }
57579
57603
  }
57580
57604
  this.acknowledge(message);
57581
- if (message.type === "REMOTE_REVISION" && message.clientId === this.clientId) {
57582
- return;
57583
- }
57584
57605
  this.trigger("collaborative-event-received");
57585
57606
  }
57586
57607
  onClientMoved(message) {
@@ -60780,8 +60801,12 @@ class GridSelectionPlugin extends UIPlugin {
60780
60801
  },
60781
60802
  ];
60782
60803
  handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
60804
+ const selection = pasteTarget[0];
60805
+ const col = selection.left;
60806
+ const row = selection.top;
60807
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
60783
60808
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
60784
- let currentIndex = cmd.base;
60809
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
60785
60810
  for (const element of toRemove) {
60786
60811
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
60787
60812
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -61064,22 +61089,33 @@ class InternalViewport {
61064
61089
  }
61065
61090
  /**
61066
61091
  *
61067
- * @param zone
61068
- * @returns Computes the absolute coordinate of a given zone inside the viewport
61092
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
61093
+ *
61069
61094
  */
61070
- getRect(zone) {
61095
+ getVisibleRect(zone) {
61071
61096
  const targetZone = intersection(zone, this);
61072
61097
  if (targetZone) {
61073
61098
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
61074
61099
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
61075
61100
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
61076
61101
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
61077
- return {
61078
- x,
61079
- y,
61080
- width,
61081
- height,
61082
- };
61102
+ return { x, y, width, height };
61103
+ }
61104
+ return undefined;
61105
+ }
61106
+ /**
61107
+ *
61108
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
61109
+ *
61110
+ */
61111
+ getFullRect(zone) {
61112
+ const targetZone = intersection(zone, this);
61113
+ if (targetZone) {
61114
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
61115
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
61116
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
61117
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
61118
+ return { x, y, width, height };
61083
61119
  }
61084
61120
  return undefined;
61085
61121
  }
@@ -61249,6 +61285,8 @@ class SheetViewPlugin extends UIPlugin {
61249
61285
  "isPositionVisible",
61250
61286
  "getColDimensionsInViewport",
61251
61287
  "getRowDimensionsInViewport",
61288
+ "getAllActiveViewportsZones",
61289
+ "getRect",
61252
61290
  ];
61253
61291
  viewports = {};
61254
61292
  /**
@@ -61635,16 +61673,27 @@ class SheetViewPlugin extends UIPlugin {
61635
61673
  getVisibleRectWithoutHeaders(zone) {
61636
61674
  const sheetId = this.getters.getActiveSheetId();
61637
61675
  const viewportRects = this.getSubViewports(sheetId)
61638
- .map((viewport) => viewport.getRect(zone))
61676
+ .map((viewport) => viewport.getVisibleRect(zone))
61639
61677
  .filter(isDefined);
61640
61678
  if (viewportRects.length === 0) {
61641
61679
  return { x: 0, y: 0, width: 0, height: 0 };
61642
61680
  }
61643
- const x = Math.min(...viewportRects.map((rect) => rect.x));
61644
- const y = Math.min(...viewportRects.map((rect) => rect.y));
61645
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
61646
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
61647
- return { x, y, width, height };
61681
+ return this.recomposeRect(viewportRects);
61682
+ }
61683
+ /**
61684
+ * Computes the actual size and position (:Rect) of the zone on the canvas
61685
+ * regardless of the viewport dimensions.
61686
+ */
61687
+ getRect(zone) {
61688
+ const sheetId = this.getters.getActiveSheetId();
61689
+ const viewportRects = this.getSubViewports(sheetId)
61690
+ .map((viewport) => viewport.getFullRect(zone))
61691
+ .filter(isDefined);
61692
+ if (viewportRects.length === 0) {
61693
+ return { x: 0, y: 0, width: 0, height: 0 };
61694
+ }
61695
+ const rect = this.recomposeRect(viewportRects);
61696
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
61648
61697
  }
61649
61698
  /**
61650
61699
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -61688,6 +61737,10 @@ class SheetViewPlugin extends UIPlugin {
61688
61737
  end: start + (isRowHidden ? 0 : size),
61689
61738
  };
61690
61739
  }
61740
+ getAllActiveViewportsZones() {
61741
+ const sheetId = this.getters.getActiveSheetId();
61742
+ return this.getSubViewports(sheetId);
61743
+ }
61691
61744
  // ---------------------------------------------------------------------------
61692
61745
  // Private
61693
61746
  // ---------------------------------------------------------------------------
@@ -61878,6 +61931,13 @@ class SheetViewPlugin extends UIPlugin {
61878
61931
  const height = this.sheetViewHeight + this.gridOffsetY;
61879
61932
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
61880
61933
  }
61934
+ recomposeRect(viewportRects) {
61935
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
61936
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
61937
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
61938
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
61939
+ return { x, y, width, height };
61940
+ }
61881
61941
  }
61882
61942
 
61883
61943
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -68803,6 +68863,6 @@ exports.tokenColors = tokenColors;
68803
68863
  exports.tokenize = tokenize;
68804
68864
 
68805
68865
 
68806
- __info__.version = "17.4.17";
68807
- __info__.date = "2025-01-14T11:34:44.930Z";
68808
- __info__.hash = "fd2a7ab";
68866
+ __info__.version = "17.4.19";
68867
+ __info__.date = "2025-01-27T10:04:10.249Z";
68868
+ __info__.hash = "f2a7840";
@@ -4942,10 +4942,16 @@ declare class InternalViewport {
4942
4942
  adjustViewportZone(): void;
4943
4943
  /**
4944
4944
  *
4945
- * @param zone
4946
- * @returns Computes the absolute coordinate of a given zone inside the viewport
4945
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
4946
+ *
4947
4947
  */
4948
- getRect(zone: Zone): Rect | undefined;
4948
+ getVisibleRect(zone: Zone): Rect | undefined;
4949
+ /**
4950
+ *
4951
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
4952
+ *
4953
+ */
4954
+ getFullRect(zone: Zone): Rect | undefined;
4949
4955
  isVisible(col: HeaderIndex, row: HeaderIndex): boolean;
4950
4956
  private searchHeaderIndex;
4951
4957
  private setViewportOffsetX;
@@ -5014,7 +5020,7 @@ type SheetViewports = {
5014
5020
  *
5015
5021
  */
5016
5022
  declare class SheetViewPlugin extends UIPlugin {
5017
- 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"];
5023
+ 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"];
5018
5024
  readonly viewports: Record<UID, SheetViewports | undefined>;
5019
5025
  /**
5020
5026
  * The viewport dimensions are usually set by one of the components
@@ -5085,6 +5091,11 @@ declare class SheetViewPlugin extends UIPlugin {
5085
5091
  * Computes the coordinates and size to draw the zone without taking the grid offset into account
5086
5092
  */
5087
5093
  getVisibleRectWithoutHeaders(zone: Zone): Rect;
5094
+ /**
5095
+ * Computes the actual size and position (:Rect) of the zone on the canvas
5096
+ * regardless of the viewport dimensions.
5097
+ */
5098
+ getRect(zone: Zone): Rect;
5088
5099
  /**
5089
5100
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
5090
5101
  * It corresponds to the summed dimensions of the visible cols/rows (in x/y respectively)
@@ -5101,6 +5112,7 @@ declare class SheetViewPlugin extends UIPlugin {
5101
5112
  * of the current viewport
5102
5113
  */
5103
5114
  getRowDimensionsInViewport(sheetId: UID, row: HeaderIndex): HeaderDimensions;
5115
+ getAllActiveViewportsZones(): Zone[];
5104
5116
  private ensureMainViewportExist;
5105
5117
  private getSubViewports;
5106
5118
  private checkPositiveDimension;
@@ -5132,6 +5144,7 @@ declare class SheetViewPlugin extends UIPlugin {
5132
5144
  xRatio: number;
5133
5145
  yRatio: number;
5134
5146
  };
5147
+ private recomposeRect;
5135
5148
  }
5136
5149
 
5137
5150
  /**