@odoo/o-spreadsheet 18.1.1 → 18.1.3

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 18.1.1
6
- * @date 2025-01-14T11:43:19.116Z
7
- * @hash d0fa5de
5
+ * @version 18.1.3
6
+ * @date 2025-01-27T10:50:23.000Z
7
+ * @hash 7ffac1e
8
8
  */
9
9
 
10
10
  'use strict';
@@ -4380,15 +4380,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4380
4380
  let currentIndex;
4381
4381
  let currentVal;
4382
4382
  let currentType;
4383
+ const getValue = sortOrder === "desc"
4384
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
4385
+ : (i) => normalizeValue(getValueInData(data, i));
4383
4386
  while (indexRight - indexLeft >= 0) {
4384
4387
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
4385
4388
  currentIndex = indexMedian;
4386
- currentVal = normalizeValue(getValueInData(data, currentIndex));
4389
+ currentVal = getValue(currentIndex);
4387
4390
  currentType = typeof currentVal;
4388
4391
  // 1 - linear search to find value with the same type
4389
4392
  while (indexLeft < currentIndex && targetType !== currentType) {
4390
4393
  currentIndex--;
4391
- currentVal = normalizeValue(getValueInData(data, currentIndex));
4394
+ currentVal = getValue(currentIndex);
4392
4395
  currentType = typeof currentVal;
4393
4396
  }
4394
4397
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -4404,8 +4407,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4404
4407
  if (matchVal === undefined ||
4405
4408
  matchVal === null ||
4406
4409
  matchVal < currentVal ||
4407
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
4408
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
4410
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
4409
4411
  matchVal = currentVal;
4410
4412
  matchValIndex = currentIndex;
4411
4413
  }
@@ -4413,15 +4415,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4413
4415
  else if (mode === "nextGreater" && currentVal >= _target) {
4414
4416
  if (matchVal === undefined ||
4415
4417
  matchVal > currentVal ||
4416
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
4417
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
4418
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
4418
4419
  matchVal = currentVal;
4419
4420
  matchValIndex = currentIndex;
4420
4421
  }
4421
4422
  }
4422
4423
  // 3 - give new indexes for the Binary search
4423
- if ((sortOrder === "asc" && currentVal > _target) ||
4424
- (sortOrder === "desc" && currentVal <= _target)) {
4424
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
4425
4425
  indexRight = currentIndex - 1;
4426
4426
  }
4427
4427
  else {
@@ -4429,7 +4429,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4429
4429
  }
4430
4430
  }
4431
4431
  // note that valMinIndex could be 0
4432
- return matchValIndex !== undefined ? matchValIndex : -1;
4432
+ if (matchValIndex === undefined) {
4433
+ return -1;
4434
+ }
4435
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
4433
4436
  }
4434
4437
  /**
4435
4438
  * Perform a linear search and return the index of the match.
@@ -32203,6 +32206,10 @@ class Popover extends owl.Component {
32203
32206
  this.currentDisplayValue = newDisplay;
32204
32207
  if (!anchor)
32205
32208
  return;
32209
+ el.style.top = "";
32210
+ el.style.left = "";
32211
+ el.style["max-height"] = "";
32212
+ el.style["max-width"] = "";
32206
32213
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
32207
32214
  let elDims = {
32208
32215
  width: el.getBoundingClientRect().width,
@@ -48638,7 +48645,7 @@ class GridComposer extends owl.Component {
48638
48645
  return;
48639
48646
  }
48640
48647
  const sheetId = this.env.model.getters.getActiveSheetId();
48641
- const zone = this.env.model.getters.getSelectedZone();
48648
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
48642
48649
  const rect = this.env.model.getters.getVisibleRect(zone);
48643
48650
  if (!deepEquals(rect, this.rect) || sheetId !== this.composerStore.currentEditedCell.sheetId) {
48644
48651
  this.isCellReferenceVisible = true;
@@ -50474,13 +50481,23 @@ class GridRenderer {
50474
50481
  drawLayer(renderingContext, layer) {
50475
50482
  switch (layer) {
50476
50483
  case "Background":
50477
- const boxes = this.getGridBoxes();
50478
- this.drawBackground(renderingContext, boxes);
50479
- this.drawOverflowingCellBackground(renderingContext, boxes);
50480
- this.drawCellBackground(renderingContext, boxes);
50481
- this.drawBorders(renderingContext, boxes);
50482
- this.drawTexts(renderingContext, boxes);
50483
- this.drawIcon(renderingContext, boxes);
50484
+ this.drawGlobalBackground(renderingContext);
50485
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
50486
+ const { ctx } = renderingContext;
50487
+ ctx.save();
50488
+ ctx.beginPath();
50489
+ const rect = this.getters.getVisibleRect(zone);
50490
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
50491
+ ctx.clip();
50492
+ const boxes = this.getGridBoxes(zone);
50493
+ this.drawBackground(renderingContext, boxes);
50494
+ this.drawOverflowingCellBackground(renderingContext, boxes);
50495
+ this.drawCellBackground(renderingContext, boxes);
50496
+ this.drawBorders(renderingContext, boxes);
50497
+ this.drawTexts(renderingContext, boxes);
50498
+ this.drawIcon(renderingContext, boxes);
50499
+ ctx.restore();
50500
+ }
50484
50501
  this.drawFrozenPanes(renderingContext);
50485
50502
  break;
50486
50503
  case "Headers":
@@ -50491,12 +50508,15 @@ class GridRenderer {
50491
50508
  break;
50492
50509
  }
50493
50510
  }
50494
- drawBackground(renderingContext, boxes) {
50495
- const { ctx, thinLineWidth } = renderingContext;
50511
+ drawGlobalBackground(renderingContext) {
50512
+ const { ctx } = renderingContext;
50496
50513
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
50497
50514
  // white background
50498
50515
  ctx.fillStyle = "#ffffff";
50499
50516
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
50517
+ }
50518
+ drawBackground(renderingContext, boxes) {
50519
+ const { ctx, thinLineWidth } = renderingContext;
50500
50520
  const areGridLinesVisible = !this.getters.isDashboard() &&
50501
50521
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
50502
50522
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -50927,7 +50947,7 @@ class GridRenderer {
50927
50947
  const position = { sheetId, col, row };
50928
50948
  const cell = this.getters.getEvaluatedCell(position);
50929
50949
  const showFormula = this.getters.shouldShowFormulas();
50930
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
50950
+ const { x, y, width, height } = this.getters.getRect(zone);
50931
50951
  const { verticalAlign } = this.getters.getCellStyle(position);
50932
50952
  let style = this.getters.getCellComputedStyle(position);
50933
50953
  if (this.fingerprints.isEnabled) {
@@ -51052,12 +51072,16 @@ class GridRenderer {
51052
51072
  }
51053
51073
  return box;
51054
51074
  }
51055
- getGridBoxes() {
51075
+ getGridBoxes(zone) {
51056
51076
  const boxes = [];
51057
- const visibleCols = this.getters.getSheetViewVisibleCols();
51077
+ const visibleCols = this.getters
51078
+ .getSheetViewVisibleCols()
51079
+ .filter((col) => col >= zone.left && col <= zone.right);
51058
51080
  const left = visibleCols[0];
51059
51081
  const right = visibleCols[visibleCols.length - 1];
51060
- const visibleRows = this.getters.getSheetViewVisibleRows();
51082
+ const visibleRows = this.getters
51083
+ .getSheetViewVisibleRows()
51084
+ .filter((row) => row >= zone.top && row <= zone.bottom);
51061
51085
  const top = visibleRows[0];
51062
51086
  const bottom = visibleRows[visibleRows.length - 1];
51063
51087
  const viewport = { left, right, top, bottom };
@@ -63392,9 +63416,6 @@ class Session extends EventBus {
63392
63416
  }
63393
63417
  }
63394
63418
  this.acknowledge(message);
63395
- if (message.type === "REMOTE_REVISION" && message.clientId === this.clientId) {
63396
- return;
63397
- }
63398
63419
  this.trigger("collaborative-event-received");
63399
63420
  }
63400
63421
  onClientMoved(message) {
@@ -66726,8 +66747,12 @@ class GridSelectionPlugin extends UIPlugin {
66726
66747
  },
66727
66748
  ];
66728
66749
  handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
66750
+ const selection = pasteTarget[0];
66751
+ const col = selection.left;
66752
+ const row = selection.top;
66753
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
66729
66754
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
66730
- let currentIndex = cmd.base;
66755
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
66731
66756
  const resizingGroups = {};
66732
66757
  for (const element of toRemove) {
66733
66758
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
@@ -67018,22 +67043,33 @@ class InternalViewport {
67018
67043
  }
67019
67044
  /**
67020
67045
  *
67021
- * @param zone
67022
- * @returns Computes the absolute coordinate of a given zone inside the viewport
67046
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
67047
+ *
67023
67048
  */
67024
- getRect(zone) {
67049
+ getVisibleRect(zone) {
67025
67050
  const targetZone = intersection(zone, this);
67026
67051
  if (targetZone) {
67027
67052
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
67028
67053
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
67029
67054
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
67030
67055
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
67031
- return {
67032
- x,
67033
- y,
67034
- width,
67035
- height,
67036
- };
67056
+ return { x, y, width, height };
67057
+ }
67058
+ return undefined;
67059
+ }
67060
+ /**
67061
+ *
67062
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
67063
+ *
67064
+ */
67065
+ getFullRect(zone) {
67066
+ const targetZone = intersection(zone, this);
67067
+ if (targetZone) {
67068
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
67069
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
67070
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
67071
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
67072
+ return { x, y, width, height };
67037
67073
  }
67038
67074
  return undefined;
67039
67075
  }
@@ -67203,6 +67239,8 @@ class SheetViewPlugin extends UIPlugin {
67203
67239
  "isPositionVisible",
67204
67240
  "getColDimensionsInViewport",
67205
67241
  "getRowDimensionsInViewport",
67242
+ "getAllActiveViewportsZones",
67243
+ "getRect",
67206
67244
  ];
67207
67245
  viewports = {};
67208
67246
  /**
@@ -67586,16 +67624,27 @@ class SheetViewPlugin extends UIPlugin {
67586
67624
  getVisibleRectWithoutHeaders(zone) {
67587
67625
  const sheetId = this.getters.getActiveSheetId();
67588
67626
  const viewportRects = this.getSubViewports(sheetId)
67589
- .map((viewport) => viewport.getRect(zone))
67627
+ .map((viewport) => viewport.getVisibleRect(zone))
67590
67628
  .filter(isDefined);
67591
67629
  if (viewportRects.length === 0) {
67592
67630
  return { x: 0, y: 0, width: 0, height: 0 };
67593
67631
  }
67594
- const x = Math.min(...viewportRects.map((rect) => rect.x));
67595
- const y = Math.min(...viewportRects.map((rect) => rect.y));
67596
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
67597
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
67598
- return { x, y, width, height };
67632
+ return this.recomposeRect(viewportRects);
67633
+ }
67634
+ /**
67635
+ * Computes the actual size and position (:Rect) of the zone on the canvas
67636
+ * regardless of the viewport dimensions.
67637
+ */
67638
+ getRect(zone) {
67639
+ const sheetId = this.getters.getActiveSheetId();
67640
+ const viewportRects = this.getSubViewports(sheetId)
67641
+ .map((viewport) => viewport.getFullRect(zone))
67642
+ .filter(isDefined);
67643
+ if (viewportRects.length === 0) {
67644
+ return { x: 0, y: 0, width: 0, height: 0 };
67645
+ }
67646
+ const rect = this.recomposeRect(viewportRects);
67647
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
67599
67648
  }
67600
67649
  /**
67601
67650
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -67639,6 +67688,10 @@ class SheetViewPlugin extends UIPlugin {
67639
67688
  end: start + (isRowHidden ? 0 : size),
67640
67689
  };
67641
67690
  }
67691
+ getAllActiveViewportsZones() {
67692
+ const sheetId = this.getters.getActiveSheetId();
67693
+ return this.getSubViewports(sheetId);
67694
+ }
67642
67695
  // ---------------------------------------------------------------------------
67643
67696
  // Private
67644
67697
  // ---------------------------------------------------------------------------
@@ -67829,6 +67882,13 @@ class SheetViewPlugin extends UIPlugin {
67829
67882
  const height = this.sheetViewHeight + this.gridOffsetY;
67830
67883
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
67831
67884
  }
67885
+ recomposeRect(viewportRects) {
67886
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
67887
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
67888
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
67889
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
67890
+ return { x, y, width, height };
67891
+ }
67832
67892
  }
67833
67893
 
67834
67894
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -74957,6 +75017,6 @@ exports.tokenColors = tokenColors;
74957
75017
  exports.tokenize = tokenize;
74958
75018
 
74959
75019
 
74960
- __info__.version = "18.1.1";
74961
- __info__.date = "2025-01-14T11:43:19.116Z";
74962
- __info__.hash = "d0fa5de";
75020
+ __info__.version = "18.1.3";
75021
+ __info__.date = "2025-01-27T10:50:23.000Z";
75022
+ __info__.hash = "7ffac1e";
@@ -2103,10 +2103,16 @@ declare class InternalViewport {
2103
2103
  adjustViewportZone(): void;
2104
2104
  /**
2105
2105
  *
2106
- * @param zone
2107
- * @returns Computes the absolute coordinate of a given zone inside the viewport
2106
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
2107
+ *
2108
2108
  */
2109
- getRect(zone: Zone): Rect | undefined;
2109
+ getVisibleRect(zone: Zone): Rect | undefined;
2110
+ /**
2111
+ *
2112
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
2113
+ *
2114
+ */
2115
+ getFullRect(zone: Zone): Rect | undefined;
2110
2116
  isVisible(col: HeaderIndex, row: HeaderIndex): boolean;
2111
2117
  private searchHeaderIndex;
2112
2118
  private setViewportOffsetX;
@@ -2175,7 +2181,7 @@ type SheetViewports = {
2175
2181
  *
2176
2182
  */
2177
2183
  declare class SheetViewPlugin extends UIPlugin {
2178
- 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"];
2184
+ 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"];
2179
2185
  readonly viewports: Record<UID, SheetViewports | undefined>;
2180
2186
  /**
2181
2187
  * The viewport dimensions are usually set by one of the components
@@ -2246,6 +2252,11 @@ declare class SheetViewPlugin extends UIPlugin {
2246
2252
  * Computes the coordinates and size to draw the zone without taking the grid offset into account
2247
2253
  */
2248
2254
  getVisibleRectWithoutHeaders(zone: Zone): Rect;
2255
+ /**
2256
+ * Computes the actual size and position (:Rect) of the zone on the canvas
2257
+ * regardless of the viewport dimensions.
2258
+ */
2259
+ getRect(zone: Zone): Rect;
2249
2260
  /**
2250
2261
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
2251
2262
  * It corresponds to the summed dimensions of the visible cols/rows (in x/y respectively)
@@ -2262,6 +2273,7 @@ declare class SheetViewPlugin extends UIPlugin {
2262
2273
  * of the current viewport
2263
2274
  */
2264
2275
  getRowDimensionsInViewport(sheetId: UID, row: HeaderIndex): HeaderDimensions;
2276
+ getAllActiveViewportsZones(): Zone[];
2265
2277
  private ensureMainViewportExist;
2266
2278
  private getSubViewports;
2267
2279
  private checkPositiveDimension;
@@ -2293,6 +2305,7 @@ declare class SheetViewPlugin extends UIPlugin {
2293
2305
  xRatio: number;
2294
2306
  yRatio: number;
2295
2307
  };
2308
+ private recomposeRect;
2296
2309
  }
2297
2310
 
2298
2311
  declare enum ClipboardMIMEType {