@odoo/o-spreadsheet 17.0.45 → 17.0.46

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.0.45
6
- * @date 2025-01-14T11:30:44.730Z
7
- * @hash 94f8ef9
5
+ * @version 17.0.46
6
+ * @date 2025-01-27T10:00:20.499Z
7
+ * @hash 1df062c
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -2696,15 +2696,18 @@
2696
2696
  let currentIndex;
2697
2697
  let currentVal;
2698
2698
  let currentType;
2699
+ const getValue = sortOrder === "desc"
2700
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2701
+ : (i) => normalizeValue(getValueInData(data, i));
2699
2702
  while (indexRight - indexLeft >= 0) {
2700
2703
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2701
2704
  currentIndex = indexMedian;
2702
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2705
+ currentVal = getValue(currentIndex);
2703
2706
  currentType = typeof currentVal;
2704
2707
  // 1 - linear search to find value with the same type
2705
2708
  while (indexLeft < currentIndex && targetType !== currentType) {
2706
2709
  currentIndex--;
2707
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2710
+ currentVal = getValue(currentIndex);
2708
2711
  currentType = typeof currentVal;
2709
2712
  }
2710
2713
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2720,8 +2723,7 @@
2720
2723
  if (matchVal === undefined ||
2721
2724
  matchVal === null ||
2722
2725
  matchVal < currentVal ||
2723
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2724
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2726
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2725
2727
  matchVal = currentVal;
2726
2728
  matchValIndex = currentIndex;
2727
2729
  }
@@ -2729,15 +2731,13 @@
2729
2731
  else if (mode === "nextGreater" && currentVal >= _target) {
2730
2732
  if (matchVal === undefined ||
2731
2733
  matchVal > currentVal ||
2732
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2733
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2734
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2734
2735
  matchVal = currentVal;
2735
2736
  matchValIndex = currentIndex;
2736
2737
  }
2737
2738
  }
2738
2739
  // 3 - give new indexes for the Binary search
2739
- if ((sortOrder === "asc" && currentVal > _target) ||
2740
- (sortOrder === "desc" && currentVal <= _target)) {
2740
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2741
2741
  indexRight = currentIndex - 1;
2742
2742
  }
2743
2743
  else {
@@ -2745,7 +2745,10 @@
2745
2745
  }
2746
2746
  }
2747
2747
  // note that valMinIndex could be 0
2748
- return matchValIndex !== undefined ? matchValIndex : -1;
2748
+ if (matchValIndex === undefined) {
2749
+ return -1;
2750
+ }
2751
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2749
2752
  }
2750
2753
  /**
2751
2754
  * Perform a linear search and return the index of the match.
@@ -6939,6 +6942,10 @@
6939
6942
  this.currentDisplayValue = newDisplay;
6940
6943
  if (!anchor)
6941
6944
  return;
6945
+ el.style.top = "";
6946
+ el.style.left = "";
6947
+ el.style["max-height"] = "";
6948
+ el.style["max-width"] = "";
6942
6949
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6943
6950
  let elDims = {
6944
6951
  width: el.getBoundingClientRect().width,
@@ -27453,7 +27460,7 @@
27453
27460
  return;
27454
27461
  }
27455
27462
  const sheetId = this.env.model.getters.getActiveSheetId();
27456
- const zone = this.env.model.getters.getSelectedZone();
27463
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
27457
27464
  const rect = this.env.model.getters.getVisibleRect(zone);
27458
27465
  if (!deepEquals(rect, this.rect) ||
27459
27466
  sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
@@ -46260,13 +46267,23 @@
46260
46267
  drawGrid(renderingContext, layer) {
46261
46268
  switch (layer) {
46262
46269
  case 0 /* LAYERS.Background */:
46263
- this.boxes = this.getGridBoxes();
46264
- this.drawBackground(renderingContext);
46265
- this.drawOverflowingCellBackground(renderingContext);
46266
- this.drawCellBackground(renderingContext);
46267
- this.drawBorders(renderingContext);
46268
- this.drawTexts(renderingContext);
46269
- this.drawIcon(renderingContext);
46270
+ this.drawGlobalBackground(renderingContext);
46271
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
46272
+ const { ctx } = renderingContext;
46273
+ ctx.save();
46274
+ ctx.beginPath();
46275
+ const rect = this.getters.getVisibleRect(zone);
46276
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
46277
+ ctx.clip();
46278
+ this.boxes = this.getGridBoxes(zone);
46279
+ this.drawBackground(renderingContext);
46280
+ this.drawOverflowingCellBackground(renderingContext);
46281
+ this.drawCellBackground(renderingContext);
46282
+ this.drawBorders(renderingContext);
46283
+ this.drawTexts(renderingContext);
46284
+ this.drawIcon(renderingContext);
46285
+ ctx.restore();
46286
+ }
46270
46287
  this.drawFrozenPanes(renderingContext);
46271
46288
  break;
46272
46289
  case 7 /* LAYERS.Headers */:
@@ -46277,12 +46294,15 @@
46277
46294
  break;
46278
46295
  }
46279
46296
  }
46280
- drawBackground(renderingContext) {
46281
- const { ctx, thinLineWidth } = renderingContext;
46297
+ drawGlobalBackground(renderingContext) {
46298
+ const { ctx } = renderingContext;
46282
46299
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
46283
46300
  // white background
46284
46301
  ctx.fillStyle = "#ffffff";
46285
46302
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
46303
+ }
46304
+ drawBackground(renderingContext) {
46305
+ const { ctx, thinLineWidth } = renderingContext;
46286
46306
  const areGridLinesVisible = !this.getters.isDashboard() &&
46287
46307
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
46288
46308
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -46713,7 +46733,7 @@
46713
46733
  const position = { sheetId, col, row };
46714
46734
  const cell = this.getters.getEvaluatedCell(position);
46715
46735
  const showFormula = this.getters.shouldShowFormulas();
46716
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
46736
+ const { x, y, width, height } = this.getters.getRect(zone);
46717
46737
  const { verticalAlign } = this.getters.getCellStyle(position);
46718
46738
  const box = {
46719
46739
  x,
@@ -46828,12 +46848,16 @@
46828
46848
  }
46829
46849
  return box;
46830
46850
  }
46831
- getGridBoxes() {
46851
+ getGridBoxes(zone) {
46832
46852
  const boxes = [];
46833
- const visibleCols = this.getters.getSheetViewVisibleCols();
46853
+ const visibleCols = this.getters
46854
+ .getSheetViewVisibleCols()
46855
+ .filter((col) => col >= zone.left && col <= zone.right);
46834
46856
  const left = visibleCols[0];
46835
46857
  const right = visibleCols[visibleCols.length - 1];
46836
- const visibleRows = this.getters.getSheetViewVisibleRows();
46858
+ const visibleRows = this.getters
46859
+ .getSheetViewVisibleRows()
46860
+ .filter((row) => row >= zone.top && row <= zone.bottom);
46837
46861
  const top = visibleRows[0];
46838
46862
  const bottom = visibleRows[visibleRows.length - 1];
46839
46863
  const viewport = { left, right, top, bottom };
@@ -50360,7 +50384,7 @@
50360
50384
  ];
50361
50385
  state.paste(pasteTarget, { selectTarget: true });
50362
50386
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50363
- let currentIndex = cmd.base;
50387
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50364
50388
  for (const element of toRemove) {
50365
50389
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50366
50390
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -50651,7 +50675,7 @@
50651
50675
  * @param zone
50652
50676
  * @returns Computes the absolute coordinate of a given zone inside the viewport
50653
50677
  */
50654
- getRect(zone) {
50678
+ getVisibleRect(zone) {
50655
50679
  const targetZone = intersection(zone, this.zone);
50656
50680
  if (targetZone) {
50657
50681
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -50659,12 +50683,20 @@
50659
50683
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
50660
50684
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
50661
50685
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
50662
- return {
50663
- x,
50664
- y,
50665
- width,
50666
- height,
50667
- };
50686
+ return { x, y, width, height };
50687
+ }
50688
+ else {
50689
+ return undefined;
50690
+ }
50691
+ }
50692
+ getFullRect(zone) {
50693
+ const targetZone = intersection(zone, this.zone);
50694
+ if (targetZone) {
50695
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
50696
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
50697
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
50698
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
50699
+ return { x, y, width, height };
50668
50700
  }
50669
50701
  else {
50670
50702
  return undefined;
@@ -50848,6 +50880,8 @@
50848
50880
  "getSheetViewVisibleRows",
50849
50881
  "getFrozenSheetViewRatio",
50850
50882
  "isPositionVisible",
50883
+ "getAllActiveViewportsZones",
50884
+ "getRect",
50851
50885
  ];
50852
50886
  viewports = {};
50853
50887
  /**
@@ -51235,16 +51269,27 @@
51235
51269
  getVisibleRectWithoutHeaders(zone) {
51236
51270
  const sheetId = this.getters.getActiveSheetId();
51237
51271
  const viewportRects = this.getSubViewports(sheetId)
51238
- .map((viewport) => viewport.getRect(zone))
51272
+ .map((viewport) => viewport.getVisibleRect(zone))
51239
51273
  .filter(isDefined$1);
51240
51274
  if (viewportRects.length === 0) {
51241
51275
  return { x: 0, y: 0, width: 0, height: 0 };
51242
51276
  }
51243
- const x = Math.min(...viewportRects.map((rect) => rect.x));
51244
- const y = Math.min(...viewportRects.map((rect) => rect.y));
51245
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51246
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51247
- return { x, y, width, height };
51277
+ return this.recomposeRect(viewportRects);
51278
+ }
51279
+ /**
51280
+ * Computes the actual size and position (:Rect) of the zone on the canvas
51281
+ * regardless of the viewport dimensions.
51282
+ */
51283
+ getRect(zone) {
51284
+ const sheetId = this.getters.getActiveSheetId();
51285
+ const viewportRects = this.getSubViewports(sheetId)
51286
+ .map((viewport) => viewport.getFullRect(zone))
51287
+ .filter(isDefined$1);
51288
+ if (viewportRects.length === 0) {
51289
+ return { x: 0, y: 0, width: 0, height: 0 };
51290
+ }
51291
+ const rect = this.recomposeRect(viewportRects);
51292
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
51248
51293
  }
51249
51294
  /**
51250
51295
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -51258,6 +51303,10 @@
51258
51303
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
51259
51304
  return { x, y };
51260
51305
  }
51306
+ getAllActiveViewportsZones() {
51307
+ const sheetId = this.getters.getActiveSheetId();
51308
+ return this.getSubViewports(sheetId);
51309
+ }
51261
51310
  // ---------------------------------------------------------------------------
51262
51311
  // Private
51263
51312
  // ---------------------------------------------------------------------------
@@ -51442,6 +51491,13 @@
51442
51491
  const height = this.sheetViewHeight + this.gridOffsetY;
51443
51492
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
51444
51493
  }
51494
+ recomposeRect(viewportRects) {
51495
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
51496
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
51497
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51498
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51499
+ return { x, y, width, height };
51500
+ }
51445
51501
  }
51446
51502
 
51447
51503
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -57749,9 +57805,9 @@
57749
57805
  exports.tokenize = tokenize;
57750
57806
 
57751
57807
 
57752
- __info__.version = "17.0.45";
57753
- __info__.date = "2025-01-14T11:30:44.730Z";
57754
- __info__.hash = "94f8ef9";
57808
+ __info__.version = "17.0.46";
57809
+ __info__.date = "2025-01-27T10:00:20.499Z";
57810
+ __info__.hash = "1df062c";
57755
57811
 
57756
57812
 
57757
57813
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);