@odoo/o-spreadsheet 17.2.31 → 17.2.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.
@@ -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.31
7
- * @date 2025-01-14T11:31:09.035Z
8
- * @hash 306dbf7
6
+ * @version 17.2.33
7
+ * @date 2025-01-27T10:02:54.985Z
8
+ * @hash 6ea43fb
9
9
  */
10
10
 
11
11
  'use strict';
@@ -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 };
@@ -50632,9 +50656,6 @@ class Session extends EventBus {
50632
50656
  }
50633
50657
  }
50634
50658
  this.acknowledge(message);
50635
- if (message.type === "REMOTE_REVISION" && message.clientId === this.clientId) {
50636
- return;
50637
- }
50638
50659
  this.trigger("collaborative-event-received");
50639
50660
  }
50640
50661
  onClientMoved(message) {
@@ -53650,8 +53671,12 @@ class GridSelectionPlugin extends UIPlugin {
53650
53671
  },
53651
53672
  ];
53652
53673
  handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
53674
+ const selection = pasteTarget[0];
53675
+ const col = selection.left;
53676
+ const row = selection.top;
53677
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
53653
53678
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
53654
- let currentIndex = cmd.base;
53679
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
53655
53680
  for (const element of toRemove) {
53656
53681
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
53657
53682
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -53930,22 +53955,33 @@ class InternalViewport {
53930
53955
  }
53931
53956
  /**
53932
53957
  *
53933
- * @param zone
53934
- * @returns Computes the absolute coordinate of a given zone inside the viewport
53958
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
53959
+ *
53935
53960
  */
53936
- getRect(zone) {
53961
+ getVisibleRect(zone) {
53937
53962
  const targetZone = intersection(zone, this);
53938
53963
  if (targetZone) {
53939
53964
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
53940
53965
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
53941
53966
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
53942
53967
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
53943
- return {
53944
- x,
53945
- y,
53946
- width,
53947
- height,
53948
- };
53968
+ return { x, y, width, height };
53969
+ }
53970
+ return undefined;
53971
+ }
53972
+ /**
53973
+ *
53974
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
53975
+ *
53976
+ */
53977
+ getFullRect(zone) {
53978
+ const targetZone = intersection(zone, this);
53979
+ if (targetZone) {
53980
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
53981
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
53982
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
53983
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
53984
+ return { x, y, width, height };
53949
53985
  }
53950
53986
  return undefined;
53951
53987
  }
@@ -54115,6 +54151,8 @@ class SheetViewPlugin extends UIPlugin {
54115
54151
  "isPositionVisible",
54116
54152
  "getColDimensionsInViewport",
54117
54153
  "getRowDimensionsInViewport",
54154
+ "getAllActiveViewportsZones",
54155
+ "getRect",
54118
54156
  ];
54119
54157
  viewports = {};
54120
54158
  /**
@@ -54502,16 +54540,27 @@ class SheetViewPlugin extends UIPlugin {
54502
54540
  getVisibleRectWithoutHeaders(zone) {
54503
54541
  const sheetId = this.getters.getActiveSheetId();
54504
54542
  const viewportRects = this.getSubViewports(sheetId)
54505
- .map((viewport) => viewport.getRect(zone))
54543
+ .map((viewport) => viewport.getVisibleRect(zone))
54506
54544
  .filter(isDefined$1);
54507
54545
  if (viewportRects.length === 0) {
54508
54546
  return { x: 0, y: 0, width: 0, height: 0 };
54509
54547
  }
54510
- const x = Math.min(...viewportRects.map((rect) => rect.x));
54511
- const y = Math.min(...viewportRects.map((rect) => rect.y));
54512
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54513
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54514
- return { x, y, width, height };
54548
+ return this.recomposeRect(viewportRects);
54549
+ }
54550
+ /**
54551
+ * Computes the actual size and position (:Rect) of the zone on the canvas
54552
+ * regardless of the viewport dimensions.
54553
+ */
54554
+ getRect(zone) {
54555
+ const sheetId = this.getters.getActiveSheetId();
54556
+ const viewportRects = this.getSubViewports(sheetId)
54557
+ .map((viewport) => viewport.getFullRect(zone))
54558
+ .filter(isDefined$1);
54559
+ if (viewportRects.length === 0) {
54560
+ return { x: 0, y: 0, width: 0, height: 0 };
54561
+ }
54562
+ const rect = this.recomposeRect(viewportRects);
54563
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
54515
54564
  }
54516
54565
  /**
54517
54566
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -54555,6 +54604,10 @@ class SheetViewPlugin extends UIPlugin {
54555
54604
  end: start + (isRowHidden ? 0 : size),
54556
54605
  };
54557
54606
  }
54607
+ getAllActiveViewportsZones() {
54608
+ const sheetId = this.getters.getActiveSheetId();
54609
+ return this.getSubViewports(sheetId);
54610
+ }
54558
54611
  // ---------------------------------------------------------------------------
54559
54612
  // Private
54560
54613
  // ---------------------------------------------------------------------------
@@ -54739,6 +54792,13 @@ class SheetViewPlugin extends UIPlugin {
54739
54792
  const height = this.sheetViewHeight + this.gridOffsetY;
54740
54793
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
54741
54794
  }
54795
+ recomposeRect(viewportRects) {
54796
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
54797
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
54798
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54799
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54800
+ return { x, y, width, height };
54801
+ }
54742
54802
  }
54743
54803
 
54744
54804
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -61076,6 +61136,6 @@ exports.tokenColors = tokenColors;
61076
61136
  exports.tokenize = tokenize;
61077
61137
 
61078
61138
 
61079
- __info__.version = "17.2.31";
61080
- __info__.date = "2025-01-14T11:31:09.035Z";
61081
- __info__.hash = "306dbf7";
61139
+ __info__.version = "17.2.33";
61140
+ __info__.date = "2025-01-27T10:02:54.985Z";
61141
+ __info__.hash = "6ea43fb";
@@ -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
  /**