@odoo/o-spreadsheet 17.2.32 → 17.2.34

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.34
7
+ * @date 2025-01-31T07:58:03.953Z
8
+ * @hash 0bffee9
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -1783,11 +1783,11 @@
1783
1783
  * number from the point of view of the isNumber function.
1784
1784
  */
1785
1785
  function parseNumber(str, locale) {
1786
+ // remove invaluable characters
1787
+ str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1786
1788
  if (locale.decimalSeparator !== ".") {
1787
1789
  str = str.replace(locale.decimalSeparator, ".");
1788
1790
  }
1789
- // remove invaluable characters
1790
- str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1791
1791
  let n = Number(str);
1792
1792
  if (isNaN(n) && str.includes("%")) {
1793
1793
  n = Number(str.split("%")[0]);
@@ -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 };
@@ -51440,14 +51464,12 @@ stores.inject(MyMetaStore, storeInstance);
51440
51464
  }
51441
51465
  break;
51442
51466
  case "AUTORESIZE_ROWS":
51443
- for (let row of cmd.rows) {
51444
- this.dispatch("RESIZE_COLUMNS_ROWS", {
51445
- elements: [row],
51446
- dimension: "ROW",
51447
- size: null,
51448
- sheetId: cmd.sheetId,
51449
- });
51450
- }
51467
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
51468
+ elements: cmd.rows,
51469
+ dimension: "ROW",
51470
+ size: null,
51471
+ sheetId: cmd.sheetId,
51472
+ });
51451
51473
  break;
51452
51474
  }
51453
51475
  }
@@ -53646,8 +53668,12 @@ stores.inject(MyMetaStore, storeInstance);
53646
53668
  },
53647
53669
  ];
53648
53670
  handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
53671
+ const selection = pasteTarget[0];
53672
+ const col = selection.left;
53673
+ const row = selection.top;
53674
+ this.setSelectionMixin({ zone: selection, cell: { col, row } }, [selection]);
53649
53675
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
53650
- let currentIndex = cmd.base;
53676
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
53651
53677
  for (const element of toRemove) {
53652
53678
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
53653
53679
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -53926,22 +53952,33 @@ stores.inject(MyMetaStore, storeInstance);
53926
53952
  }
53927
53953
  /**
53928
53954
  *
53929
- * @param zone
53930
- * @returns Computes the absolute coordinate of a given zone inside the viewport
53955
+ * Computes the visible coordinates & dimensions of a given zone inside the viewport
53956
+ *
53931
53957
  */
53932
- getRect(zone) {
53958
+ getVisibleRect(zone) {
53933
53959
  const targetZone = intersection(zone, this);
53934
53960
  if (targetZone) {
53935
53961
  const x = this.getters.getColRowOffset("COL", this.left, targetZone.left) + this.offsetCorrectionX;
53936
53962
  const y = this.getters.getColRowOffset("ROW", this.top, targetZone.top) + this.offsetCorrectionY;
53937
53963
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
53938
53964
  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
- };
53965
+ return { x, y, width, height };
53966
+ }
53967
+ return undefined;
53968
+ }
53969
+ /**
53970
+ *
53971
+ * @returns Computes the absolute coordinates & dimensions of a given zone inside the viewport
53972
+ *
53973
+ */
53974
+ getFullRect(zone) {
53975
+ const targetZone = intersection(zone, this);
53976
+ if (targetZone) {
53977
+ const x = this.getters.getColRowOffset("COL", this.left, zone.left) + this.offsetCorrectionX;
53978
+ const y = this.getters.getColRowOffset("ROW", this.top, zone.top) + this.offsetCorrectionY;
53979
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
53980
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
53981
+ return { x, y, width, height };
53945
53982
  }
53946
53983
  return undefined;
53947
53984
  }
@@ -54111,6 +54148,8 @@ stores.inject(MyMetaStore, storeInstance);
54111
54148
  "isPositionVisible",
54112
54149
  "getColDimensionsInViewport",
54113
54150
  "getRowDimensionsInViewport",
54151
+ "getAllActiveViewportsZones",
54152
+ "getRect",
54114
54153
  ];
54115
54154
  viewports = {};
54116
54155
  /**
@@ -54498,16 +54537,27 @@ stores.inject(MyMetaStore, storeInstance);
54498
54537
  getVisibleRectWithoutHeaders(zone) {
54499
54538
  const sheetId = this.getters.getActiveSheetId();
54500
54539
  const viewportRects = this.getSubViewports(sheetId)
54501
- .map((viewport) => viewport.getRect(zone))
54540
+ .map((viewport) => viewport.getVisibleRect(zone))
54502
54541
  .filter(isDefined$1);
54503
54542
  if (viewportRects.length === 0) {
54504
54543
  return { x: 0, y: 0, width: 0, height: 0 };
54505
54544
  }
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 };
54545
+ return this.recomposeRect(viewportRects);
54546
+ }
54547
+ /**
54548
+ * Computes the actual size and position (:Rect) of the zone on the canvas
54549
+ * regardless of the viewport dimensions.
54550
+ */
54551
+ getRect(zone) {
54552
+ const sheetId = this.getters.getActiveSheetId();
54553
+ const viewportRects = this.getSubViewports(sheetId)
54554
+ .map((viewport) => viewport.getFullRect(zone))
54555
+ .filter(isDefined$1);
54556
+ if (viewportRects.length === 0) {
54557
+ return { x: 0, y: 0, width: 0, height: 0 };
54558
+ }
54559
+ const rect = this.recomposeRect(viewportRects);
54560
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
54511
54561
  }
54512
54562
  /**
54513
54563
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -54551,6 +54601,10 @@ stores.inject(MyMetaStore, storeInstance);
54551
54601
  end: start + (isRowHidden ? 0 : size),
54552
54602
  };
54553
54603
  }
54604
+ getAllActiveViewportsZones() {
54605
+ const sheetId = this.getters.getActiveSheetId();
54606
+ return this.getSubViewports(sheetId);
54607
+ }
54554
54608
  // ---------------------------------------------------------------------------
54555
54609
  // Private
54556
54610
  // ---------------------------------------------------------------------------
@@ -54735,6 +54789,13 @@ stores.inject(MyMetaStore, storeInstance);
54735
54789
  const height = this.sheetViewHeight + this.gridOffsetY;
54736
54790
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
54737
54791
  }
54792
+ recomposeRect(viewportRects) {
54793
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
54794
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
54795
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
54796
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
54797
+ return { x, y, width, height };
54798
+ }
54738
54799
  }
54739
54800
 
54740
54801
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -61072,9 +61133,9 @@ stores.inject(MyMetaStore, storeInstance);
61072
61133
  exports.tokenize = tokenize;
61073
61134
 
61074
61135
 
61075
- __info__.version = "17.2.32";
61076
- __info__.date = "2025-01-15T08:03:19.290Z";
61077
- __info__.hash = "e12286d";
61136
+ __info__.version = "17.2.34";
61137
+ __info__.date = "2025-01-31T07:58:03.953Z";
61138
+ __info__.hash = "0bffee9";
61078
61139
 
61079
61140
 
61080
61141
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);