@odoo/o-spreadsheet 17.2.32 → 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.32
7
- * @date 2025-01-15T08:03:19.290Z
8
- * @hash e12286d
6
+ * @version 17.2.33
7
+ * @date 2025-01-27T10:02:54.985Z
8
+ * @hash 6ea43fb
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -2806,15 +2806,18 @@
2806
2806
  let currentIndex;
2807
2807
  let currentVal;
2808
2808
  let currentType;
2809
+ const getValue = sortOrder === "desc"
2810
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2811
+ : (i) => normalizeValue(getValueInData(data, i));
2809
2812
  while (indexRight - indexLeft >= 0) {
2810
2813
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2811
2814
  currentIndex = indexMedian;
2812
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2815
+ currentVal = getValue(currentIndex);
2813
2816
  currentType = typeof currentVal;
2814
2817
  // 1 - linear search to find value with the same type
2815
2818
  while (indexLeft < currentIndex && targetType !== currentType) {
2816
2819
  currentIndex--;
2817
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2820
+ currentVal = getValue(currentIndex);
2818
2821
  currentType = typeof currentVal;
2819
2822
  }
2820
2823
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2830,8 +2833,7 @@
2830
2833
  if (matchVal === undefined ||
2831
2834
  matchVal === null ||
2832
2835
  matchVal < currentVal ||
2833
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2834
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2836
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2835
2837
  matchVal = currentVal;
2836
2838
  matchValIndex = currentIndex;
2837
2839
  }
@@ -2839,15 +2841,13 @@
2839
2841
  else if (mode === "nextGreater" && currentVal >= _target) {
2840
2842
  if (matchVal === undefined ||
2841
2843
  matchVal > currentVal ||
2842
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2843
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2844
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2844
2845
  matchVal = currentVal;
2845
2846
  matchValIndex = currentIndex;
2846
2847
  }
2847
2848
  }
2848
2849
  // 3 - give new indexes for the Binary search
2849
- if ((sortOrder === "asc" && currentVal > _target) ||
2850
- (sortOrder === "desc" && currentVal <= _target)) {
2850
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2851
2851
  indexRight = currentIndex - 1;
2852
2852
  }
2853
2853
  else {
@@ -2855,7 +2855,10 @@
2855
2855
  }
2856
2856
  }
2857
2857
  // note that valMinIndex could be 0
2858
- return matchValIndex !== undefined ? matchValIndex : -1;
2858
+ if (matchValIndex === undefined) {
2859
+ return -1;
2860
+ }
2861
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2859
2862
  }
2860
2863
  /**
2861
2864
  * Perform a linear search and return the index of the match.
@@ -21876,6 +21879,10 @@ stores.inject(MyMetaStore, storeInstance);
21876
21879
  this.currentDisplayValue = newDisplay;
21877
21880
  if (!anchor)
21878
21881
  return;
21882
+ el.style.top = "";
21883
+ el.style.left = "";
21884
+ el.style["max-height"] = "";
21885
+ el.style["max-width"] = "";
21879
21886
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
21880
21887
  let elDims = {
21881
21888
  width: el.getBoundingClientRect().width,
@@ -32942,7 +32949,7 @@ stores.inject(MyMetaStore, storeInstance);
32942
32949
  return;
32943
32950
  }
32944
32951
  const sheetId = this.env.model.getters.getActiveSheetId();
32945
- const zone = this.env.model.getters.getSelectedZone();
32952
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
32946
32953
  const rect = this.env.model.getters.getVisibleRect(zone);
32947
32954
  if (!deepEquals(rect, this.rect) || sheetId !== this.composerStore.currentEditedCell.sheetId) {
32948
32955
  this.isCellReferenceVisible = true;
@@ -34688,13 +34695,23 @@ stores.inject(MyMetaStore, storeInstance);
34688
34695
  drawLayer(renderingContext, layer) {
34689
34696
  switch (layer) {
34690
34697
  case "Background":
34691
- const boxes = this.getGridBoxes();
34692
- this.drawBackground(renderingContext, boxes);
34693
- this.drawOverflowingCellBackground(renderingContext, boxes);
34694
- this.drawCellBackground(renderingContext, boxes);
34695
- this.drawBorders(renderingContext, boxes);
34696
- this.drawTexts(renderingContext, boxes);
34697
- this.drawIcon(renderingContext, boxes);
34698
+ this.drawGlobalBackground(renderingContext);
34699
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
34700
+ const { ctx } = renderingContext;
34701
+ ctx.save();
34702
+ ctx.beginPath();
34703
+ const rect = this.getters.getVisibleRect(zone);
34704
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
34705
+ ctx.clip();
34706
+ const boxes = this.getGridBoxes(zone);
34707
+ this.drawBackground(renderingContext, boxes);
34708
+ this.drawOverflowingCellBackground(renderingContext, boxes);
34709
+ this.drawCellBackground(renderingContext, boxes);
34710
+ this.drawBorders(renderingContext, boxes);
34711
+ this.drawTexts(renderingContext, boxes);
34712
+ this.drawIcon(renderingContext, boxes);
34713
+ ctx.restore();
34714
+ }
34698
34715
  this.drawFrozenPanes(renderingContext);
34699
34716
  break;
34700
34717
  case "Headers":
@@ -34705,12 +34722,15 @@ stores.inject(MyMetaStore, storeInstance);
34705
34722
  break;
34706
34723
  }
34707
34724
  }
34708
- drawBackground(renderingContext, boxes) {
34709
- const { ctx, thinLineWidth } = renderingContext;
34725
+ drawGlobalBackground(renderingContext) {
34726
+ const { ctx } = renderingContext;
34710
34727
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
34711
34728
  // white background
34712
34729
  ctx.fillStyle = "#ffffff";
34713
34730
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
34731
+ }
34732
+ drawBackground(renderingContext, boxes) {
34733
+ const { ctx, thinLineWidth } = renderingContext;
34714
34734
  const areGridLinesVisible = !this.getters.isDashboard() &&
34715
34735
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
34716
34736
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -35135,7 +35155,7 @@ stores.inject(MyMetaStore, storeInstance);
35135
35155
  const position = { sheetId, col, row };
35136
35156
  const cell = this.getters.getEvaluatedCell(position);
35137
35157
  const showFormula = this.getters.shouldShowFormulas();
35138
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
35158
+ const { x, y, width, height } = this.getters.getRect(zone);
35139
35159
  const { verticalAlign } = this.getters.getCellStyle(position);
35140
35160
  const box = {
35141
35161
  x,
@@ -35250,12 +35270,16 @@ stores.inject(MyMetaStore, storeInstance);
35250
35270
  }
35251
35271
  return box;
35252
35272
  }
35253
- getGridBoxes() {
35273
+ getGridBoxes(zone) {
35254
35274
  const boxes = [];
35255
- const visibleCols = this.getters.getSheetViewVisibleCols();
35275
+ const visibleCols = this.getters
35276
+ .getSheetViewVisibleCols()
35277
+ .filter((col) => col >= zone.left && col <= zone.right);
35256
35278
  const left = visibleCols[0];
35257
35279
  const right = visibleCols[visibleCols.length - 1];
35258
- const visibleRows = this.getters.getSheetViewVisibleRows();
35280
+ const visibleRows = this.getters
35281
+ .getSheetViewVisibleRows()
35282
+ .filter((row) => row >= zone.top && row <= zone.bottom);
35259
35283
  const top = visibleRows[0];
35260
35284
  const bottom = visibleRows[visibleRows.length - 1];
35261
35285
  const viewport = { left, right, top, bottom };
@@ -53646,8 +53670,12 @@ stores.inject(MyMetaStore, storeInstance);
53646
53670
  },
53647
53671
  ];
53648
53672
  handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
53673
+ const selection = pasteTarget[0];
53674
+ const col = selection.left;
53675
+ const row = selection.top;
53676
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
53649
53677
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
53650
- let currentIndex = cmd.base;
53678
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
53651
53679
  for (const element of toRemove) {
53652
53680
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
53653
53681
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -53926,22 +53954,33 @@ stores.inject(MyMetaStore, storeInstance);
53926
53954
  }
53927
53955
  /**
53928
53956
  *
53929
- * @param zone
53930
- * @returns Computes the absolute coordinate of a given zone inside the viewport
53957
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
53958
+ *
53931
53959
  */
53932
- getRect(zone) {
53960
+ getVisibleRect(zone) {
53933
53961
  const targetZone = intersection(zone, this);
53934
53962
  if (targetZone) {
53935
53963
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
53936
53964
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
53937
53965
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
53938
53966
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
53939
- return {
53940
- x,
53941
- y,
53942
- width,
53943
- height,
53944
- };
53967
+ return { x, y, width, height };
53968
+ }
53969
+ return undefined;
53970
+ }
53971
+ /**
53972
+ *
53973
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
53974
+ *
53975
+ */
53976
+ getFullRect(zone) {
53977
+ const targetZone = intersection(zone, this);
53978
+ if (targetZone) {
53979
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
53980
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
53981
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
53982
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
53983
+ return { x, y, width, height };
53945
53984
  }
53946
53985
  return undefined;
53947
53986
  }
@@ -54111,6 +54150,8 @@ stores.inject(MyMetaStore, storeInstance);
54111
54150
  "isPositionVisible",
54112
54151
  "getColDimensionsInViewport",
54113
54152
  "getRowDimensionsInViewport",
54153
+ "getAllActiveViewportsZones",
54154
+ "getRect",
54114
54155
  ];
54115
54156
  viewports = {};
54116
54157
  /**
@@ -54498,16 +54539,27 @@ stores.inject(MyMetaStore, storeInstance);
54498
54539
  getVisibleRectWithoutHeaders(zone) {
54499
54540
  const sheetId = this.getters.getActiveSheetId();
54500
54541
  const viewportRects = this.getSubViewports(sheetId)
54501
- .map((viewport) => viewport.getRect(zone))
54542
+ .map((viewport) => viewport.getVisibleRect(zone))
54502
54543
  .filter(isDefined$1);
54503
54544
  if (viewportRects.length === 0) {
54504
54545
  return { x: 0, y: 0, width: 0, height: 0 };
54505
54546
  }
54506
- const x = Math.min(...viewportRects.map((rect) => rect.x));
54507
- const y = Math.min(...viewportRects.map((rect) => rect.y));
54508
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54509
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54510
- return { x, y, width, height };
54547
+ return this.recomposeRect(viewportRects);
54548
+ }
54549
+ /**
54550
+ * Computes the actual size and position (:Rect) of the zone on the canvas
54551
+ * regardless of the viewport dimensions.
54552
+ */
54553
+ getRect(zone) {
54554
+ const sheetId = this.getters.getActiveSheetId();
54555
+ const viewportRects = this.getSubViewports(sheetId)
54556
+ .map((viewport) => viewport.getFullRect(zone))
54557
+ .filter(isDefined$1);
54558
+ if (viewportRects.length === 0) {
54559
+ return { x: 0, y: 0, width: 0, height: 0 };
54560
+ }
54561
+ const rect = this.recomposeRect(viewportRects);
54562
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
54511
54563
  }
54512
54564
  /**
54513
54565
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -54551,6 +54603,10 @@ stores.inject(MyMetaStore, storeInstance);
54551
54603
  end: start + (isRowHidden ? 0 : size),
54552
54604
  };
54553
54605
  }
54606
+ getAllActiveViewportsZones() {
54607
+ const sheetId = this.getters.getActiveSheetId();
54608
+ return this.getSubViewports(sheetId);
54609
+ }
54554
54610
  // ---------------------------------------------------------------------------
54555
54611
  // Private
54556
54612
  // ---------------------------------------------------------------------------
@@ -54735,6 +54791,13 @@ stores.inject(MyMetaStore, storeInstance);
54735
54791
  const height = this.sheetViewHeight + this.gridOffsetY;
54736
54792
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
54737
54793
  }
54794
+ recomposeRect(viewportRects) {
54795
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
54796
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
54797
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54798
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54799
+ return { x, y, width, height };
54800
+ }
54738
54801
  }
54739
54802
 
54740
54803
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -61072,9 +61135,9 @@ stores.inject(MyMetaStore, storeInstance);
61072
61135
  exports.tokenize = tokenize;
61073
61136
 
61074
61137
 
61075
- __info__.version = "17.2.32";
61076
- __info__.date = "2025-01-15T08:03:19.290Z";
61077
- __info__.hash = "e12286d";
61138
+ __info__.version = "17.2.33";
61139
+ __info__.date = "2025-01-27T10:02:54.985Z";
61140
+ __info__.hash = "6ea43fb";
61078
61141
 
61079
61142
 
61080
61143
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);