@odoo/o-spreadsheet 18.1.2 → 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.2
6
- * @date 2025-01-15T08:06:07.728Z
7
- * @hash 002aa4a
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 };
@@ -66723,8 +66747,12 @@ class GridSelectionPlugin extends UIPlugin {
66723
66747
  },
66724
66748
  ];
66725
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]);
66726
66754
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
66727
- let currentIndex = cmd.base;
66755
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
66728
66756
  const resizingGroups = {};
66729
66757
  for (const element of toRemove) {
66730
66758
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
@@ -67015,22 +67043,33 @@ class InternalViewport {
67015
67043
  }
67016
67044
  /**
67017
67045
  *
67018
- * @param zone
67019
- * @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
+ *
67020
67048
  */
67021
- getRect(zone) {
67049
+ getVisibleRect(zone) {
67022
67050
  const targetZone = intersection(zone, this);
67023
67051
  if (targetZone) {
67024
67052
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
67025
67053
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
67026
67054
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
67027
67055
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
67028
- return {
67029
- x,
67030
- y,
67031
- width,
67032
- height,
67033
- };
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 };
67034
67073
  }
67035
67074
  return undefined;
67036
67075
  }
@@ -67200,6 +67239,8 @@ class SheetViewPlugin extends UIPlugin {
67200
67239
  "isPositionVisible",
67201
67240
  "getColDimensionsInViewport",
67202
67241
  "getRowDimensionsInViewport",
67242
+ "getAllActiveViewportsZones",
67243
+ "getRect",
67203
67244
  ];
67204
67245
  viewports = {};
67205
67246
  /**
@@ -67583,16 +67624,27 @@ class SheetViewPlugin extends UIPlugin {
67583
67624
  getVisibleRectWithoutHeaders(zone) {
67584
67625
  const sheetId = this.getters.getActiveSheetId();
67585
67626
  const viewportRects = this.getSubViewports(sheetId)
67586
- .map((viewport) => viewport.getRect(zone))
67627
+ .map((viewport) => viewport.getVisibleRect(zone))
67587
67628
  .filter(isDefined);
67588
67629
  if (viewportRects.length === 0) {
67589
67630
  return { x: 0, y: 0, width: 0, height: 0 };
67590
67631
  }
67591
- const x = Math.min(...viewportRects.map((rect) => rect.x));
67592
- const y = Math.min(...viewportRects.map((rect) => rect.y));
67593
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
67594
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
67595
- 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 };
67596
67648
  }
67597
67649
  /**
67598
67650
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -67636,6 +67688,10 @@ class SheetViewPlugin extends UIPlugin {
67636
67688
  end: start + (isRowHidden ? 0 : size),
67637
67689
  };
67638
67690
  }
67691
+ getAllActiveViewportsZones() {
67692
+ const sheetId = this.getters.getActiveSheetId();
67693
+ return this.getSubViewports(sheetId);
67694
+ }
67639
67695
  // ---------------------------------------------------------------------------
67640
67696
  // Private
67641
67697
  // ---------------------------------------------------------------------------
@@ -67826,6 +67882,13 @@ class SheetViewPlugin extends UIPlugin {
67826
67882
  const height = this.sheetViewHeight + this.gridOffsetY;
67827
67883
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
67828
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
+ }
67829
67892
  }
67830
67893
 
67831
67894
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -74954,6 +75017,6 @@ exports.tokenColors = tokenColors;
74954
75017
  exports.tokenize = tokenize;
74955
75018
 
74956
75019
 
74957
- __info__.version = "18.1.2";
74958
- __info__.date = "2025-01-15T08:06:07.728Z";
74959
- __info__.hash = "002aa4a";
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 {
@@ -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.2
6
- * @date 2025-01-15T08:06:07.728Z
7
- * @hash 002aa4a
5
+ * @version 18.1.3
6
+ * @date 2025-01-27T10:50:23.000Z
7
+ * @hash 7ffac1e
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -4378,15 +4378,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4378
4378
  let currentIndex;
4379
4379
  let currentVal;
4380
4380
  let currentType;
4381
+ const getValue = sortOrder === "desc"
4382
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
4383
+ : (i) => normalizeValue(getValueInData(data, i));
4381
4384
  while (indexRight - indexLeft >= 0) {
4382
4385
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
4383
4386
  currentIndex = indexMedian;
4384
- currentVal = normalizeValue(getValueInData(data, currentIndex));
4387
+ currentVal = getValue(currentIndex);
4385
4388
  currentType = typeof currentVal;
4386
4389
  // 1 - linear search to find value with the same type
4387
4390
  while (indexLeft < currentIndex && targetType !== currentType) {
4388
4391
  currentIndex--;
4389
- currentVal = normalizeValue(getValueInData(data, currentIndex));
4392
+ currentVal = getValue(currentIndex);
4390
4393
  currentType = typeof currentVal;
4391
4394
  }
4392
4395
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -4402,8 +4405,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4402
4405
  if (matchVal === undefined ||
4403
4406
  matchVal === null ||
4404
4407
  matchVal < currentVal ||
4405
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
4406
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
4408
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
4407
4409
  matchVal = currentVal;
4408
4410
  matchValIndex = currentIndex;
4409
4411
  }
@@ -4411,15 +4413,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4411
4413
  else if (mode === "nextGreater" && currentVal >= _target) {
4412
4414
  if (matchVal === undefined ||
4413
4415
  matchVal > currentVal ||
4414
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
4415
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
4416
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
4416
4417
  matchVal = currentVal;
4417
4418
  matchValIndex = currentIndex;
4418
4419
  }
4419
4420
  }
4420
4421
  // 3 - give new indexes for the Binary search
4421
- if ((sortOrder === "asc" && currentVal > _target) ||
4422
- (sortOrder === "desc" && currentVal <= _target)) {
4422
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
4423
4423
  indexRight = currentIndex - 1;
4424
4424
  }
4425
4425
  else {
@@ -4427,7 +4427,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
4427
4427
  }
4428
4428
  }
4429
4429
  // note that valMinIndex could be 0
4430
- return matchValIndex !== undefined ? matchValIndex : -1;
4430
+ if (matchValIndex === undefined) {
4431
+ return -1;
4432
+ }
4433
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
4431
4434
  }
4432
4435
  /**
4433
4436
  * Perform a linear search and return the index of the match.
@@ -32201,6 +32204,10 @@ class Popover extends Component {
32201
32204
  this.currentDisplayValue = newDisplay;
32202
32205
  if (!anchor)
32203
32206
  return;
32207
+ el.style.top = "";
32208
+ el.style.left = "";
32209
+ el.style["max-height"] = "";
32210
+ el.style["max-width"] = "";
32204
32211
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
32205
32212
  let elDims = {
32206
32213
  width: el.getBoundingClientRect().width,
@@ -48636,7 +48643,7 @@ class GridComposer extends Component {
48636
48643
  return;
48637
48644
  }
48638
48645
  const sheetId = this.env.model.getters.getActiveSheetId();
48639
- const zone = this.env.model.getters.getSelectedZone();
48646
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
48640
48647
  const rect = this.env.model.getters.getVisibleRect(zone);
48641
48648
  if (!deepEquals(rect, this.rect) || sheetId !== this.composerStore.currentEditedCell.sheetId) {
48642
48649
  this.isCellReferenceVisible = true;
@@ -50472,13 +50479,23 @@ class GridRenderer {
50472
50479
  drawLayer(renderingContext, layer) {
50473
50480
  switch (layer) {
50474
50481
  case "Background":
50475
- const boxes = this.getGridBoxes();
50476
- this.drawBackground(renderingContext, boxes);
50477
- this.drawOverflowingCellBackground(renderingContext, boxes);
50478
- this.drawCellBackground(renderingContext, boxes);
50479
- this.drawBorders(renderingContext, boxes);
50480
- this.drawTexts(renderingContext, boxes);
50481
- this.drawIcon(renderingContext, boxes);
50482
+ this.drawGlobalBackground(renderingContext);
50483
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
50484
+ const { ctx } = renderingContext;
50485
+ ctx.save();
50486
+ ctx.beginPath();
50487
+ const rect = this.getters.getVisibleRect(zone);
50488
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
50489
+ ctx.clip();
50490
+ const boxes = this.getGridBoxes(zone);
50491
+ this.drawBackground(renderingContext, boxes);
50492
+ this.drawOverflowingCellBackground(renderingContext, boxes);
50493
+ this.drawCellBackground(renderingContext, boxes);
50494
+ this.drawBorders(renderingContext, boxes);
50495
+ this.drawTexts(renderingContext, boxes);
50496
+ this.drawIcon(renderingContext, boxes);
50497
+ ctx.restore();
50498
+ }
50482
50499
  this.drawFrozenPanes(renderingContext);
50483
50500
  break;
50484
50501
  case "Headers":
@@ -50489,12 +50506,15 @@ class GridRenderer {
50489
50506
  break;
50490
50507
  }
50491
50508
  }
50492
- drawBackground(renderingContext, boxes) {
50493
- const { ctx, thinLineWidth } = renderingContext;
50509
+ drawGlobalBackground(renderingContext) {
50510
+ const { ctx } = renderingContext;
50494
50511
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
50495
50512
  // white background
50496
50513
  ctx.fillStyle = "#ffffff";
50497
50514
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
50515
+ }
50516
+ drawBackground(renderingContext, boxes) {
50517
+ const { ctx, thinLineWidth } = renderingContext;
50498
50518
  const areGridLinesVisible = !this.getters.isDashboard() &&
50499
50519
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
50500
50520
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -50925,7 +50945,7 @@ class GridRenderer {
50925
50945
  const position = { sheetId, col, row };
50926
50946
  const cell = this.getters.getEvaluatedCell(position);
50927
50947
  const showFormula = this.getters.shouldShowFormulas();
50928
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
50948
+ const { x, y, width, height } = this.getters.getRect(zone);
50929
50949
  const { verticalAlign } = this.getters.getCellStyle(position);
50930
50950
  let style = this.getters.getCellComputedStyle(position);
50931
50951
  if (this.fingerprints.isEnabled) {
@@ -51050,12 +51070,16 @@ class GridRenderer {
51050
51070
  }
51051
51071
  return box;
51052
51072
  }
51053
- getGridBoxes() {
51073
+ getGridBoxes(zone) {
51054
51074
  const boxes = [];
51055
- const visibleCols = this.getters.getSheetViewVisibleCols();
51075
+ const visibleCols = this.getters
51076
+ .getSheetViewVisibleCols()
51077
+ .filter((col) => col >= zone.left && col <= zone.right);
51056
51078
  const left = visibleCols[0];
51057
51079
  const right = visibleCols[visibleCols.length - 1];
51058
- const visibleRows = this.getters.getSheetViewVisibleRows();
51080
+ const visibleRows = this.getters
51081
+ .getSheetViewVisibleRows()
51082
+ .filter((row) => row >= zone.top && row <= zone.bottom);
51059
51083
  const top = visibleRows[0];
51060
51084
  const bottom = visibleRows[visibleRows.length - 1];
51061
51085
  const viewport = { left, right, top, bottom };
@@ -66721,8 +66745,12 @@ class GridSelectionPlugin extends UIPlugin {
66721
66745
  },
66722
66746
  ];
66723
66747
  handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
66748
+ const selection = pasteTarget[0];
66749
+ const col = selection.left;
66750
+ const row = selection.top;
66751
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
66724
66752
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
66725
- let currentIndex = cmd.base;
66753
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
66726
66754
  const resizingGroups = {};
66727
66755
  for (const element of toRemove) {
66728
66756
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
@@ -67013,22 +67041,33 @@ class InternalViewport {
67013
67041
  }
67014
67042
  /**
67015
67043
  *
67016
- * @param zone
67017
- * @returns Computes the absolute coordinate of a given zone inside the viewport
67044
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
67045
+ *
67018
67046
  */
67019
- getRect(zone) {
67047
+ getVisibleRect(zone) {
67020
67048
  const targetZone = intersection(zone, this);
67021
67049
  if (targetZone) {
67022
67050
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
67023
67051
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
67024
67052
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
67025
67053
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
67026
- return {
67027
- x,
67028
- y,
67029
- width,
67030
- height,
67031
- };
67054
+ return { x, y, width, height };
67055
+ }
67056
+ return undefined;
67057
+ }
67058
+ /**
67059
+ *
67060
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
67061
+ *
67062
+ */
67063
+ getFullRect(zone) {
67064
+ const targetZone = intersection(zone, this);
67065
+ if (targetZone) {
67066
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
67067
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
67068
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
67069
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
67070
+ return { x, y, width, height };
67032
67071
  }
67033
67072
  return undefined;
67034
67073
  }
@@ -67198,6 +67237,8 @@ class SheetViewPlugin extends UIPlugin {
67198
67237
  "isPositionVisible",
67199
67238
  "getColDimensionsInViewport",
67200
67239
  "getRowDimensionsInViewport",
67240
+ "getAllActiveViewportsZones",
67241
+ "getRect",
67201
67242
  ];
67202
67243
  viewports = {};
67203
67244
  /**
@@ -67581,16 +67622,27 @@ class SheetViewPlugin extends UIPlugin {
67581
67622
  getVisibleRectWithoutHeaders(zone) {
67582
67623
  const sheetId = this.getters.getActiveSheetId();
67583
67624
  const viewportRects = this.getSubViewports(sheetId)
67584
- .map((viewport) => viewport.getRect(zone))
67625
+ .map((viewport) => viewport.getVisibleRect(zone))
67585
67626
  .filter(isDefined);
67586
67627
  if (viewportRects.length === 0) {
67587
67628
  return { x: 0, y: 0, width: 0, height: 0 };
67588
67629
  }
67589
- const x = Math.min(...viewportRects.map((rect) => rect.x));
67590
- const y = Math.min(...viewportRects.map((rect) => rect.y));
67591
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
67592
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
67593
- return { x, y, width, height };
67630
+ return this.recomposeRect(viewportRects);
67631
+ }
67632
+ /**
67633
+ * Computes the actual size and position (:Rect) of the zone on the canvas
67634
+ * regardless of the viewport dimensions.
67635
+ */
67636
+ getRect(zone) {
67637
+ const sheetId = this.getters.getActiveSheetId();
67638
+ const viewportRects = this.getSubViewports(sheetId)
67639
+ .map((viewport) => viewport.getFullRect(zone))
67640
+ .filter(isDefined);
67641
+ if (viewportRects.length === 0) {
67642
+ return { x: 0, y: 0, width: 0, height: 0 };
67643
+ }
67644
+ const rect = this.recomposeRect(viewportRects);
67645
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
67594
67646
  }
67595
67647
  /**
67596
67648
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -67634,6 +67686,10 @@ class SheetViewPlugin extends UIPlugin {
67634
67686
  end: start + (isRowHidden ? 0 : size),
67635
67687
  };
67636
67688
  }
67689
+ getAllActiveViewportsZones() {
67690
+ const sheetId = this.getters.getActiveSheetId();
67691
+ return this.getSubViewports(sheetId);
67692
+ }
67637
67693
  // ---------------------------------------------------------------------------
67638
67694
  // Private
67639
67695
  // ---------------------------------------------------------------------------
@@ -67824,6 +67880,13 @@ class SheetViewPlugin extends UIPlugin {
67824
67880
  const height = this.sheetViewHeight + this.gridOffsetY;
67825
67881
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
67826
67882
  }
67883
+ recomposeRect(viewportRects) {
67884
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
67885
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
67886
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
67887
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
67888
+ return { x, y, width, height };
67889
+ }
67827
67890
  }
67828
67891
 
67829
67892
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -74908,6 +74971,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
74908
74971
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
74909
74972
 
74910
74973
 
74911
- __info__.version = "18.1.2";
74912
- __info__.date = "2025-01-15T08:06:07.728Z";
74913
- __info__.hash = "002aa4a";
74974
+ __info__.version = "18.1.3";
74975
+ __info__.date = "2025-01-27T10:50:23.000Z";
74976
+ __info__.hash = "7ffac1e";