@odoo/o-spreadsheet 17.4.20 → 17.4.22

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.4.20
6
- * @date 2025-01-31T08:00:07.103Z
7
- * @hash 54a344a
5
+ * @version 17.4.22
6
+ * @date 2025-02-10T09:14:48.889Z
7
+ * @hash 667f2b1
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';
@@ -746,9 +746,16 @@ function deepEqualsArray(arr1, arr2) {
746
746
  }
747
747
  return true;
748
748
  }
749
- /** Check if the given array contains all the values of the other array. */
749
+ /**
750
+ * Check if the given array contains all the values of the other array.
751
+ * It makes the assumption that both array do not contain duplicates.
752
+ */
750
753
  function includesAll(arr, values) {
751
- return values.every((value) => arr.includes(value));
754
+ if (arr.length < values.length) {
755
+ return false;
756
+ }
757
+ const set = new Set(arr);
758
+ return values.every((value) => set.has(value));
752
759
  }
753
760
  /**
754
761
  * Return an object with all the keys in the object that have a falsy value removed.
@@ -18881,22 +18888,23 @@ const HLOOKUP = {
18881
18888
  description: _t("Horizontal lookup"),
18882
18889
  args: [
18883
18890
  arg("search_key (any)", _t("The value to search for. For example, 42, 'Cats', or I24.")),
18884
- arg("range (range)", _t("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),
18891
+ arg("range (any, range)", _t("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),
18885
18892
  arg("index (number)", _t("The row index of the value to be returned, where the first row in range is numbered 1.")),
18886
18893
  arg(`is_sorted (boolean, default=${DEFAULT_IS_SORTED})`, _t("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")),
18887
18894
  ],
18888
18895
  compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
18889
18896
  const _index = Math.trunc(toNumber(index?.value, this.locale));
18890
- assert(() => 1 <= _index && _index <= range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
18897
+ const _range = toMatrix(range);
18898
+ assert(() => 1 <= _index && _index <= _range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
18891
18899
  if (searchKey && isEvaluationError(searchKey.value)) {
18892
18900
  return searchKey;
18893
18901
  }
18894
18902
  const getValueFromRange = (range, index) => range[index][0].value;
18895
18903
  const _isSorted = toBoolean(isSorted.value);
18896
18904
  const colIndex = _isSorted
18897
- ? dichotomicSearch(range, searchKey, "nextSmaller", "asc", range.length, getValueFromRange)
18898
- : linearSearch(range, searchKey, "wildcard", range.length, getValueFromRange);
18899
- const col = range[colIndex];
18905
+ ? dichotomicSearch(_range, searchKey, "nextSmaller", "asc", _range.length, getValueFromRange)
18906
+ : linearSearch(_range, searchKey, "wildcard", _range.length, getValueFromRange);
18907
+ const col = _range[colIndex];
18900
18908
  if (col === undefined) {
18901
18909
  return valueNotAvailable(searchKey);
18902
18910
  }
@@ -18995,35 +19003,37 @@ const LOOKUP = {
18995
19003
  description: _t("Look up a value."),
18996
19004
  args: [
18997
19005
  arg("search_key (any)", _t("The value to search for. For example, 42, 'Cats', or I24.")),
18998
- arg("search_array (range)", _t("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),
18999
- arg("result_range (range, optional)", _t("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")),
19006
+ arg("search_array (any, range)", _t("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),
19007
+ arg("result_range (any, range, optional)", _t("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")),
19000
19008
  ],
19001
19009
  compute: function (searchKey, searchArray, resultRange) {
19002
- let nbCol = searchArray.length;
19003
- let nbRow = searchArray[0].length;
19010
+ const _searchArray = toMatrix(searchArray);
19011
+ const _resultRange = toMatrix(resultRange);
19012
+ let nbCol = _searchArray.length;
19013
+ let nbRow = _searchArray[0].length;
19004
19014
  const verticalSearch = nbRow >= nbCol;
19005
19015
  const getElement = verticalSearch
19006
19016
  ? (range, index) => range[0][index].value
19007
19017
  : (range, index) => range[index][0].value;
19008
19018
  const rangeLength = verticalSearch ? nbRow : nbCol;
19009
- const index = dichotomicSearch(searchArray, searchKey, "nextSmaller", "asc", rangeLength, getElement);
19019
+ const index = dichotomicSearch(_searchArray, searchKey, "nextSmaller", "asc", rangeLength, getElement);
19010
19020
  if (index === -1 ||
19011
- (verticalSearch && searchArray[0][index] === undefined) ||
19012
- (!verticalSearch && searchArray[index][nbRow - 1] === undefined)) {
19021
+ (verticalSearch && _searchArray[0][index] === undefined) ||
19022
+ (!verticalSearch && _searchArray[index][nbRow - 1] === undefined)) {
19013
19023
  return valueNotAvailable(searchKey);
19014
19024
  }
19015
- if (resultRange === undefined) {
19016
- return verticalSearch ? searchArray[nbCol - 1][index] : searchArray[index][nbRow - 1];
19025
+ if (_resultRange[0].length === 0) {
19026
+ return verticalSearch ? _searchArray[nbCol - 1][index] : _searchArray[index][nbRow - 1];
19017
19027
  }
19018
- nbCol = resultRange.length;
19019
- nbRow = resultRange[0].length;
19028
+ nbCol = _resultRange.length;
19029
+ nbRow = _resultRange[0].length;
19020
19030
  assert(() => nbCol === 1 || nbRow === 1, _t("The result_range must be a single row or a single column."));
19021
19031
  if (nbCol > 1) {
19022
19032
  assert(() => index <= nbCol - 1, _t("[[FUNCTION_NAME]] evaluates to an out of range row value %s.", (index + 1).toString()));
19023
- return resultRange[index][0];
19033
+ return _resultRange[index][0];
19024
19034
  }
19025
19035
  assert(() => index <= nbRow - 1, _t("[[FUNCTION_NAME]] evaluates to an out of range column value %s.", (index + 1).toString()));
19026
- return resultRange[0][index];
19036
+ return _resultRange[0][index];
19027
19037
  },
19028
19038
  isExported: true,
19029
19039
  };
@@ -19040,28 +19050,29 @@ const MATCH = {
19040
19050
  ],
19041
19051
  compute: function (searchKey, range, searchType = { value: DEFAULT_SEARCH_TYPE }) {
19042
19052
  let _searchType = toNumber(searchType, this.locale);
19043
- const nbCol = range.length;
19044
- const nbRow = range[0].length;
19053
+ const _range = toMatrix(range);
19054
+ const nbCol = _range.length;
19055
+ const nbRow = _range[0].length;
19045
19056
  assert(() => nbCol === 1 || nbRow === 1, _t("The range must be a single row or a single column."));
19046
19057
  let index = -1;
19047
19058
  const getElement = nbCol === 1
19048
- ? (range, index) => range[0][index].value
19049
- : (range, index) => range[index][0].value;
19050
- const rangeLen = nbCol === 1 ? range[0].length : range.length;
19059
+ ? (_range, index) => _range[0][index].value
19060
+ : (_range, index) => _range[index][0].value;
19061
+ const rangeLen = nbCol === 1 ? _range[0].length : _range.length;
19051
19062
  _searchType = Math.sign(_searchType);
19052
19063
  switch (_searchType) {
19053
19064
  case 1:
19054
- index = dichotomicSearch(range, searchKey, "nextSmaller", "asc", rangeLen, getElement);
19065
+ index = dichotomicSearch(_range, searchKey, "nextSmaller", "asc", rangeLen, getElement);
19055
19066
  break;
19056
19067
  case 0:
19057
- index = linearSearch(range, searchKey, "wildcard", rangeLen, getElement);
19068
+ index = linearSearch(_range, searchKey, "wildcard", rangeLen, getElement);
19058
19069
  break;
19059
19070
  case -1:
19060
- index = dichotomicSearch(range, searchKey, "nextGreater", "desc", rangeLen, getElement);
19071
+ index = dichotomicSearch(_range, searchKey, "nextGreater", "desc", rangeLen, getElement);
19061
19072
  break;
19062
19073
  }
19063
- if ((nbCol === 1 && range[0][index] === undefined) ||
19064
- (nbCol !== 1 && range[index] === undefined)) {
19074
+ if ((nbCol === 1 && _range[0][index] === undefined) ||
19075
+ (nbCol !== 1 && _range[index] === undefined)) {
19065
19076
  return valueNotAvailable(searchKey);
19066
19077
  }
19067
19078
  return index + 1;
@@ -19115,16 +19126,17 @@ const VLOOKUP = {
19115
19126
  ],
19116
19127
  compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
19117
19128
  const _index = Math.trunc(toNumber(index?.value, this.locale));
19118
- assert(() => 1 <= _index && _index <= range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
19129
+ const _range = toMatrix(range);
19130
+ assert(() => 1 <= _index && _index <= _range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
19119
19131
  if (searchKey && isEvaluationError(searchKey.value)) {
19120
19132
  return searchKey;
19121
19133
  }
19122
19134
  const getValueFromRange = (range, index) => range[0][index].value;
19123
19135
  const _isSorted = toBoolean(isSorted.value);
19124
19136
  const rowIndex = _isSorted
19125
- ? dichotomicSearch(range, searchKey, "nextSmaller", "asc", range[0].length, getValueFromRange)
19126
- : linearSearch(range, searchKey, "wildcard", range[0].length, getValueFromRange);
19127
- const value = range[_index - 1][rowIndex];
19137
+ ? dichotomicSearch(_range, searchKey, "nextSmaller", "asc", _range[0].length, getValueFromRange)
19138
+ : linearSearch(_range, searchKey, "wildcard", _range[0].length, getValueFromRange);
19139
+ const value = _range[_index - 1][rowIndex];
19128
19140
  if (value === undefined) {
19129
19141
  return valueNotAvailable(searchKey);
19130
19142
  }
@@ -19161,30 +19173,32 @@ const XLOOKUP = {
19161
19173
  compute: function (searchKey, lookupRange, returnRange, defaultValue, matchMode = { value: DEFAULT_MATCH_MODE }, searchMode = { value: DEFAULT_SEARCH_MODE }) {
19162
19174
  const _matchMode = Math.trunc(toNumber(matchMode.value, this.locale));
19163
19175
  const _searchMode = Math.trunc(toNumber(searchMode.value, this.locale));
19164
- assert(() => lookupRange.length === 1 || lookupRange[0].length === 1, _t("lookup_range should be either a single row or single column."));
19176
+ const _lookupRange = toMatrix(lookupRange);
19177
+ const _returnRange = toMatrix(returnRange);
19178
+ assert(() => _lookupRange.length === 1 || _lookupRange[0].length === 1, _t("lookup_range should be either a single row or single column."));
19165
19179
  assert(() => [-1, 1, -2, 2].includes(_searchMode), _t("search_mode should be a value in [-1, 1, -2, 2]."));
19166
19180
  assert(() => [-1, 0, 1, 2].includes(_matchMode), _t("match_mode should be a value in [-1, 0, 1, 2]."));
19167
- const lookupDirection = lookupRange.length === 1 ? "col" : "row";
19181
+ const lookupDirection = _lookupRange.length === 1 ? "col" : "row";
19168
19182
  assert(() => !(_matchMode === 2 && [-2, 2].includes(_searchMode)), _t("the search and match mode combination is not supported for XLOOKUP evaluation."));
19169
19183
  assert(() => lookupDirection === "col"
19170
- ? returnRange[0].length === lookupRange[0].length
19171
- : returnRange.length === lookupRange.length, _t("return_range should have the same dimensions as lookup_range."));
19184
+ ? _returnRange[0].length === _lookupRange[0].length
19185
+ : _returnRange.length === _lookupRange.length, _t("return_range should have the same dimensions as lookup_range."));
19172
19186
  if (searchKey && isEvaluationError(searchKey.value)) {
19173
19187
  return [[searchKey]];
19174
19188
  }
19175
19189
  const getElement = lookupDirection === "col"
19176
19190
  ? (range, index) => range[0][index].value
19177
19191
  : (range, index) => range[index][0].value;
19178
- const rangeLen = lookupDirection === "col" ? lookupRange[0].length : lookupRange.length;
19192
+ const rangeLen = lookupDirection === "col" ? _lookupRange[0].length : _lookupRange.length;
19179
19193
  const mode = MATCH_MODE[_matchMode];
19180
19194
  const reverseSearch = _searchMode === -1;
19181
19195
  const index = _searchMode === 2 || _searchMode === -2
19182
- ? dichotomicSearch(lookupRange, searchKey, mode, _searchMode === 2 ? "asc" : "desc", rangeLen, getElement)
19183
- : linearSearch(lookupRange, searchKey, mode, rangeLen, getElement, reverseSearch);
19196
+ ? dichotomicSearch(_lookupRange, searchKey, mode, _searchMode === 2 ? "asc" : "desc", rangeLen, getElement)
19197
+ : linearSearch(_lookupRange, searchKey, mode, rangeLen, getElement, reverseSearch);
19184
19198
  if (index !== -1) {
19185
19199
  return lookupDirection === "col"
19186
- ? returnRange.map((col) => [col[index]])
19187
- : [returnRange[index]];
19200
+ ? _returnRange.map((col) => [col[index]])
19201
+ : [_returnRange[index]];
19188
19202
  }
19189
19203
  if (defaultValue === undefined) {
19190
19204
  return valueNotAvailable(searchKey);
@@ -33538,8 +33552,8 @@ function useDragAndDropListItems() {
33538
33552
  document.body.style.cursor = "move";
33539
33553
  state.draggedItemId = args.draggedItemId;
33540
33554
  const container = direction === "horizontal"
33541
- ? new HorizontalContainer(args.containerEl)
33542
- : new VerticalContainer(args.containerEl);
33555
+ ? new HorizontalContainer(args.scrollableContainerEl)
33556
+ : new VerticalContainer(args.scrollableContainerEl);
33543
33557
  dndHelper = new DOMDndHelper({
33544
33558
  ...args,
33545
33559
  container,
@@ -33550,8 +33564,8 @@ function useDragAndDropListItems() {
33550
33564
  const stopListening = startDnd(dndHelper.onMouseMove.bind(dndHelper), dndHelper.onMouseUp.bind(dndHelper));
33551
33565
  cleanupFns.push(stopListening);
33552
33566
  const onScroll = dndHelper.onScroll.bind(dndHelper);
33553
- args.containerEl.addEventListener("scroll", onScroll);
33554
- cleanupFns.push(() => args.containerEl.removeEventListener("scroll", onScroll));
33567
+ args.scrollableContainerEl.addEventListener("scroll", onScroll);
33568
+ cleanupFns.push(() => args.scrollableContainerEl.removeEventListener("scroll", onScroll));
33555
33569
  cleanupFns.push(dndHelper.destroy.bind(dndHelper));
33556
33570
  };
33557
33571
  onWillUnmount(() => {
@@ -33999,7 +34013,7 @@ class ConditionalFormatPreviewList extends Component {
33999
34013
  draggedItemId: cf.id,
34000
34014
  initialMousePosition: event.clientY,
34001
34015
  items: items,
34002
- containerEl: this.cfListRef.el,
34016
+ scrollableContainerEl: this.cfListRef.el,
34003
34017
  onDragEnd: (cfId, finalIndex) => this.onDragEnd(cfId, finalIndex),
34004
34018
  });
34005
34019
  }
@@ -36011,6 +36025,7 @@ class PivotLayoutConfigurator extends Component {
36011
36025
  unusedMeasureFields: Array,
36012
36026
  unusedDateTimeGranularities: Object,
36013
36027
  allGranularities: Array,
36028
+ getScrollableContainerEl: { type: Function, optional: true },
36014
36029
  };
36015
36030
  dimensionsRef = useRef("pivot-dimensions");
36016
36031
  dragAndDrop = useDragAndDropListItems();
@@ -36039,7 +36054,7 @@ class PivotLayoutConfigurator extends Component {
36039
36054
  draggedItemId: dimension.nameWithGranularity,
36040
36055
  initialMousePosition: event.clientY,
36041
36056
  items: draggableItems,
36042
- containerEl: this.dimensionsRef.el,
36057
+ scrollableContainerEl: this.props.getScrollableContainerEl?.() || this.dimensionsRef.el,
36043
36058
  onDragEnd: (dimensionName, finalIndex) => {
36044
36059
  const originalIndex = draggableIds.findIndex((id) => id === dimensionName);
36045
36060
  if (originalIndex === finalIndex) {
@@ -36079,7 +36094,7 @@ class PivotLayoutConfigurator extends Component {
36079
36094
  draggedItemId: measure.name,
36080
36095
  initialMousePosition: event.clientY,
36081
36096
  items: draggableItems,
36082
- containerEl: this.dimensionsRef.el,
36097
+ scrollableContainerEl: this.props.getScrollableContainerEl?.() || this.dimensionsRef.el,
36083
36098
  onDragEnd: (measureName, finalIndex) => {
36084
36099
  const originalIndex = draggableIds.findIndex((id) => id === measureName);
36085
36100
  if (originalIndex === finalIndex) {
@@ -37518,6 +37533,7 @@ class PivotSpreadsheetSidePanel extends Component {
37518
37533
  };
37519
37534
  store;
37520
37535
  state;
37536
+ pivotSidePanelRef = useRef("pivotSidePanel");
37521
37537
  setup() {
37522
37538
  this.store = useLocalStore(PivotSidePanelStore, this.props.pivotId);
37523
37539
  this.state = useState({
@@ -37546,6 +37562,9 @@ class PivotSpreadsheetSidePanel extends Component {
37546
37562
  get definition() {
37547
37563
  return this.store.definition;
37548
37564
  }
37565
+ getScrollableContainerEl() {
37566
+ return this.pivotSidePanelRef.el;
37567
+ }
37549
37568
  onSelectionChanged(ranges) {
37550
37569
  this.state.rangeHasChanged = true;
37551
37570
  this.state.range = ranges[0];
@@ -41218,11 +41237,10 @@ class GridRenderer {
41218
41237
  switch (layer) {
41219
41238
  case "Background":
41220
41239
  this.drawGlobalBackground(renderingContext);
41221
- for (const zone of this.getters.getAllActiveViewportsZones()) {
41240
+ for (const { zone, rect } of this.getters.getAllActiveViewportsZonesAndRect()) {
41222
41241
  const { ctx } = renderingContext;
41223
41242
  ctx.save();
41224
41243
  ctx.beginPath();
41225
- const rect = this.getters.getVisibleRect(zone);
41226
41244
  ctx.rect(rect.x, rect.y, rect.width, rect.height);
41227
41245
  ctx.clip();
41228
41246
  const boxes = this.getGridBoxes(zone);
@@ -41492,10 +41510,8 @@ class GridRenderer {
41492
41510
  const { ctx, thinLineWidth } = renderingContext;
41493
41511
  const visibleCols = this.getters.getSheetViewVisibleCols();
41494
41512
  const left = visibleCols[0];
41495
- const right = visibleCols[visibleCols.length - 1];
41496
41513
  const visibleRows = this.getters.getSheetViewVisibleRows();
41497
41514
  const top = visibleRows[0];
41498
- const bottom = visibleRows[visibleRows.length - 1];
41499
41515
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
41500
41516
  const selection = this.getters.getSelectedZones();
41501
41517
  const selectedCols = getZonesCols(selection);
@@ -41511,7 +41527,7 @@ class GridRenderer {
41511
41527
  ctx.lineWidth = thinLineWidth;
41512
41528
  ctx.strokeStyle = "#333";
41513
41529
  // Columns headers background
41514
- for (let col = left; col <= right; col++) {
41530
+ for (const col of visibleCols) {
41515
41531
  const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 };
41516
41532
  const { x, width } = this.getters.getVisibleRect(colZone);
41517
41533
  const isColActive = activeCols.has(col);
@@ -41528,7 +41544,7 @@ class GridRenderer {
41528
41544
  ctx.fillRect(x, 0, width, HEADER_HEIGHT);
41529
41545
  }
41530
41546
  // Rows headers background
41531
- for (let row = top; row <= bottom; row++) {
41547
+ for (const row of visibleRows) {
41532
41548
  const rowZone = { top: row, bottom: row, left: 0, right: numberOfCols - 1 };
41533
41549
  const { y, height } = this.getters.getVisibleRect(rowZone);
41534
41550
  const isRowActive = activeRows.has(row);
@@ -41554,21 +41570,21 @@ class GridRenderer {
41554
41570
  ctx.stroke();
41555
41571
  ctx.beginPath();
41556
41572
  // column text + separator
41557
- for (const i of visibleCols) {
41558
- const colSize = this.getters.getColSize(sheetId, i);
41559
- const colName = numberToLetters(i);
41560
- ctx.fillStyle = activeCols.has(i) ? "#fff" : TEXT_HEADER_COLOR;
41561
- let colStart = this.getHeaderOffset("COL", left, i);
41573
+ for (const col of visibleCols) {
41574
+ const colSize = this.getters.getColSize(sheetId, col);
41575
+ const colName = numberToLetters(col);
41576
+ ctx.fillStyle = activeCols.has(col) ? "#fff" : TEXT_HEADER_COLOR;
41577
+ let colStart = this.getHeaderOffset("COL", left, col);
41562
41578
  ctx.fillText(colName, colStart + colSize / 2, HEADER_HEIGHT / 2);
41563
41579
  ctx.moveTo(colStart + colSize, 0);
41564
41580
  ctx.lineTo(colStart + colSize, HEADER_HEIGHT);
41565
41581
  }
41566
41582
  // row text + separator
41567
- for (const i of visibleRows) {
41568
- const rowSize = this.getters.getRowSize(sheetId, i);
41569
- ctx.fillStyle = activeRows.has(i) ? "#fff" : TEXT_HEADER_COLOR;
41570
- let rowStart = this.getHeaderOffset("ROW", top, i);
41571
- ctx.fillText(String(i + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
41583
+ for (const row of visibleRows) {
41584
+ const rowSize = this.getters.getRowSize(sheetId, row);
41585
+ ctx.fillStyle = activeRows.has(row) ? "#fff" : TEXT_HEADER_COLOR;
41586
+ let rowStart = this.getHeaderOffset("ROW", top, row);
41587
+ ctx.fillText(String(row + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
41572
41588
  ctx.moveTo(0, rowStart + rowSize);
41573
41589
  ctx.lineTo(HEADER_WIDTH, rowStart + rowSize);
41574
41590
  }
@@ -41866,6 +41882,9 @@ function useGridDrawing(refName, model, canvasSize) {
41866
41882
  canvas.width = width * dpr;
41867
41883
  canvas.height = height * dpr;
41868
41884
  canvas.setAttribute("style", `width:${width}px;height:${height}px;`);
41885
+ if (width === 0 || height === 0) {
41886
+ return;
41887
+ }
41869
41888
  // Imagine each pixel as a large square. The whole-number coordinates (0, 1, 2…)
41870
41889
  // are the edges of the squares. If you draw a one-unit-wide line between whole-number
41871
41890
  // coordinates, it will overlap opposite sides of the pixel square, and the resulting
@@ -47598,7 +47617,7 @@ class BordersPlugin extends CorePlugin {
47598
47617
  getCommonSides(border1, border2) {
47599
47618
  const commonBorder = {};
47600
47619
  for (let side of ["top", "bottom", "left", "right"]) {
47601
- if (border1[side] && border1[side] === border2[side]) {
47620
+ if (border1[side] && deepEquals(border1[side], border2[side])) {
47602
47621
  commonBorder[side] = border1[side];
47603
47622
  }
47604
47623
  }
@@ -60941,8 +60960,17 @@ class InternalViewport {
60941
60960
  this.getters = getters;
60942
60961
  this.sheetId = sheetId;
60943
60962
  this.boundaries = boundaries;
60944
- this.viewportWidth = sizeInGrid.width;
60945
- this.viewportHeight = sizeInGrid.height;
60963
+ if (sizeInGrid.width < 0 || sizeInGrid.height < 0) {
60964
+ throw new Error("Viewport size cannot be negative");
60965
+ }
60966
+ this.viewportWidth = sizeInGrid.height && sizeInGrid.width;
60967
+ this.viewportHeight = sizeInGrid.width && sizeInGrid.height;
60968
+ this.top = boundaries.top;
60969
+ this.bottom = boundaries.bottom;
60970
+ this.left = boundaries.left;
60971
+ this.right = boundaries.right;
60972
+ this.offsetX = offsets.x;
60973
+ this.offsetY = offsets.y;
60946
60974
  this.offsetScrollbarX = offsets.x;
60947
60975
  this.offsetScrollbarY = offsets.y;
60948
60976
  this.canScrollVertically = options.canScrollVertically;
@@ -60985,9 +61013,9 @@ class InternalViewport {
60985
61013
  Math.min(topRowSize, this.viewportHeight - lastRowSize) // Add pixels that allows the snapping at maximum vertical scroll
60986
61014
  );
60987
61015
  height = Math.max(height, this.viewportHeight); // if the viewport grid size is smaller than its client height, return client height
60988
- }
60989
- if (lastRowEnd + FOOTER_HEIGHT > height && !this.getters.isReadonly()) {
60990
- height += FOOTER_HEIGHT;
61016
+ if (lastRowEnd + FOOTER_HEIGHT > height && !this.getters.isReadonly()) {
61017
+ height += FOOTER_HEIGHT;
61018
+ }
60991
61019
  }
60992
61020
  return { width, height };
60993
61021
  }
@@ -61128,6 +61156,9 @@ class InternalViewport {
61128
61156
  !this.getters.isRowHidden(this.sheetId, row));
61129
61157
  }
61130
61158
  searchHeaderIndex(dimension, position, startIndex = 0) {
61159
+ if (this.viewportWidth <= 0 || this.viewportHeight <= 0) {
61160
+ return -1;
61161
+ }
61131
61162
  const sheetId = this.sheetId;
61132
61163
  const headers = this.getters.getNumberHeaders(sheetId, dimension);
61133
61164
  // using a binary search:
@@ -61164,7 +61195,7 @@ class InternalViewport {
61164
61195
  this.adjustViewportZoneY();
61165
61196
  }
61166
61197
  /** Corrects the viewport's horizontal offset based on the current structure
61167
- * To make sure that at least on column is visible inside the viewport.
61198
+ * To make sure that at least one column is visible inside the viewport.
61168
61199
  */
61169
61200
  adjustViewportOffsetX() {
61170
61201
  if (this.canScrollHorizontally) {
@@ -61176,7 +61207,7 @@ class InternalViewport {
61176
61207
  this.adjustViewportZoneX();
61177
61208
  }
61178
61209
  /** Corrects the viewport's vertical offset based on the current structure
61179
- * To make sure that at least on row is visible inside the viewport.
61210
+ * To make sure that at least one row is visible inside the viewport.
61180
61211
  */
61181
61212
  adjustViewportOffsetY() {
61182
61213
  if (this.canScrollVertically) {
@@ -61193,11 +61224,14 @@ class InternalViewport {
61193
61224
  const sheetId = this.sheetId;
61194
61225
  this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
61195
61226
  this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
61227
+ if (!this.viewportWidth) {
61228
+ return;
61229
+ }
61196
61230
  if (this.left === -1) {
61197
61231
  this.left = this.boundaries.left;
61198
61232
  }
61199
61233
  if (this.right === -1) {
61200
- this.right = this.getters.getNumberCols(sheetId) - 1;
61234
+ this.right = this.boundaries.right;
61201
61235
  }
61202
61236
  this.offsetX =
61203
61237
  this.getters.getColDimensions(sheetId, this.left).start -
@@ -61209,11 +61243,14 @@ class InternalViewport {
61209
61243
  const sheetId = this.sheetId;
61210
61244
  this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
61211
61245
  this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
61246
+ if (!this.viewportHeight) {
61247
+ return;
61248
+ }
61212
61249
  if (this.top === -1) {
61213
61250
  this.top = this.boundaries.top;
61214
61251
  }
61215
61252
  if (this.bottom === -1) {
61216
- this.bottom = this.getters.getNumberRows(sheetId) - 1;
61253
+ this.bottom = this.boundaries.bottom;
61217
61254
  }
61218
61255
  this.offsetY =
61219
61256
  this.getters.getRowDimensions(sheetId, this.top).start -
@@ -61287,7 +61324,7 @@ class SheetViewPlugin extends UIPlugin {
61287
61324
  "isPositionVisible",
61288
61325
  "getColDimensionsInViewport",
61289
61326
  "getRowDimensionsInViewport",
61290
- "getAllActiveViewportsZones",
61327
+ "getAllActiveViewportsZonesAndRect",
61291
61328
  "getRect",
61292
61329
  ];
61293
61330
  viewports = {};
@@ -61520,12 +61557,12 @@ class SheetViewPlugin extends UIPlugin {
61520
61557
  const sheetId = this.getters.getActiveSheetId();
61521
61558
  const viewports = this.getSubViewports(sheetId);
61522
61559
  //TODO ake another commit to eimprove this
61523
- return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => !this.getters.isHeaderHidden(sheetId, "COL", col));
61560
+ return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => col >= 0 && !this.getters.isHeaderHidden(sheetId, "COL", col));
61524
61561
  }
61525
61562
  getSheetViewVisibleRows() {
61526
61563
  const sheetId = this.getters.getActiveSheetId();
61527
61564
  const viewports = this.getSubViewports(sheetId);
61528
- return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => !this.getters.isHeaderHidden(sheetId, "ROW", row));
61565
+ return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => row >= 0 && !this.getters.isHeaderHidden(sheetId, "ROW", row));
61529
61566
  }
61530
61567
  /**
61531
61568
  * Get the positions of all the cells that are visible in the viewport, taking merges into account.
@@ -61568,19 +61605,19 @@ class SheetViewPlugin extends UIPlugin {
61568
61605
  maxOffsetY: Math.max(0, height - viewport.viewportHeight + 1),
61569
61606
  };
61570
61607
  }
61571
- getColRowOffsetInViewport(dimension, referenceIndex, index) {
61572
- const sheetId = this.getters.getActiveSheetId();
61573
- const visibleCols = this.getters.getSheetViewVisibleCols();
61574
- const visibleRows = this.getters.getSheetViewVisibleRows();
61575
- if (index < referenceIndex) {
61576
- return -this.getColRowOffsetInViewport(dimension, index, referenceIndex);
61608
+ getColRowOffsetInViewport(dimension, referenceHeaderIndex, targetHeaderIndex) {
61609
+ if (targetHeaderIndex < referenceHeaderIndex) {
61610
+ return -this.getColRowOffsetInViewport(dimension, targetHeaderIndex, referenceHeaderIndex);
61577
61611
  }
61612
+ const sheetId = this.getters.getActiveSheetId();
61613
+ const visibleHeaders = dimension === "COL"
61614
+ ? this.getters.getSheetViewVisibleCols()
61615
+ : this.getters.getSheetViewVisibleRows();
61616
+ const startIndex = visibleHeaders.findIndex((header) => referenceHeaderIndex >= header);
61617
+ const endIndex = visibleHeaders.findIndex((header) => targetHeaderIndex <= header);
61618
+ const relevantIndexes = visibleHeaders.slice(startIndex, endIndex);
61578
61619
  let offset = 0;
61579
- const visibleIndexes = dimension === "COL" ? visibleCols : visibleRows;
61580
- for (let i = referenceIndex; i < index; i++) {
61581
- if (!visibleIndexes.includes(i)) {
61582
- continue;
61583
- }
61620
+ for (const i of relevantIndexes) {
61584
61621
  offset += this.getters.getHeaderSize(sheetId, dimension, i);
61585
61622
  }
61586
61623
  return offset;
@@ -61627,7 +61664,7 @@ class SheetViewPlugin extends UIPlugin {
61627
61664
  }
61628
61665
  return { canEdgeScroll, direction, delay };
61629
61666
  }
61630
- getEdgeScrollRow(y, previousY, tartingY) {
61667
+ getEdgeScrollRow(y, previousY, startingY) {
61631
61668
  let canEdgeScroll = false;
61632
61669
  let direction = 0;
61633
61670
  let delay = 0;
@@ -61648,7 +61685,7 @@ class SheetViewPlugin extends UIPlugin {
61648
61685
  delay = scrollDelay(y - height);
61649
61686
  direction = 1;
61650
61687
  }
61651
- else if (y < offsetCorrectionY && tartingY >= offsetCorrectionY && currentOffsetY > 0) {
61688
+ else if (y < offsetCorrectionY && startingY >= offsetCorrectionY && currentOffsetY > 0) {
61652
61689
  // 2
61653
61690
  canEdgeScroll = true;
61654
61691
  delay = scrollDelay(offsetCorrectionY - y);
@@ -61674,13 +61711,7 @@ class SheetViewPlugin extends UIPlugin {
61674
61711
  */
61675
61712
  getVisibleRectWithoutHeaders(zone) {
61676
61713
  const sheetId = this.getters.getActiveSheetId();
61677
- const viewportRects = this.getSubViewports(sheetId)
61678
- .map((viewport) => viewport.getVisibleRect(zone))
61679
- .filter(isDefined);
61680
- if (viewportRects.length === 0) {
61681
- return { x: 0, y: 0, width: 0, height: 0 };
61682
- }
61683
- return this.recomposeRect(viewportRects);
61714
+ return this.mapViewportsToRect(sheetId, (viewport) => viewport.getVisibleRect(zone));
61684
61715
  }
61685
61716
  /**
61686
61717
  * Computes the actual size and position (:Rect) of the zone on the canvas
@@ -61688,13 +61719,7 @@ class SheetViewPlugin extends UIPlugin {
61688
61719
  */
61689
61720
  getRect(zone) {
61690
61721
  const sheetId = this.getters.getActiveSheetId();
61691
- const viewportRects = this.getSubViewports(sheetId)
61692
- .map((viewport) => viewport.getFullRect(zone))
61693
- .filter(isDefined);
61694
- if (viewportRects.length === 0) {
61695
- return { x: 0, y: 0, width: 0, height: 0 };
61696
- }
61697
- const rect = this.recomposeRect(viewportRects);
61722
+ const rect = this.mapViewportsToRect(sheetId, (viewport) => viewport.getFullRect(zone));
61698
61723
  return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
61699
61724
  }
61700
61725
  /**
@@ -61739,9 +61764,18 @@ class SheetViewPlugin extends UIPlugin {
61739
61764
  end: start + (isRowHidden ? 0 : size),
61740
61765
  };
61741
61766
  }
61742
- getAllActiveViewportsZones() {
61767
+ getAllActiveViewportsZonesAndRect() {
61743
61768
  const sheetId = this.getters.getActiveSheetId();
61744
- return this.getSubViewports(sheetId);
61769
+ return this.getSubViewports(sheetId).map((viewport) => {
61770
+ return {
61771
+ zone: viewport,
61772
+ rect: {
61773
+ x: viewport.offsetCorrectionX + this.gridOffsetX,
61774
+ y: viewport.offsetCorrectionY + this.gridOffsetY,
61775
+ ...viewport.getMaxSize(),
61776
+ },
61777
+ };
61778
+ });
61745
61779
  }
61746
61780
  // ---------------------------------------------------------------------------
61747
61781
  // Private
@@ -61800,12 +61834,11 @@ class SheetViewPlugin extends UIPlugin {
61800
61834
  }
61801
61835
  /** gets rid of deprecated sheetIds */
61802
61836
  cleanViewports() {
61803
- const sheetIds = this.getters.getSheetIds();
61804
- for (let sheetId of Object.keys(this.viewports)) {
61805
- if (!sheetIds.includes(sheetId)) {
61806
- delete this.viewports[sheetId];
61807
- }
61837
+ const newViewport = {};
61838
+ for (const sheetId of this.getters.getSheetIds()) {
61839
+ newViewport[sheetId] = this.viewports[sheetId];
61808
61840
  }
61841
+ this.viewports = newViewport;
61809
61842
  }
61810
61843
  resizeSheetView(height, width, gridOffsetX = 0, gridOffsetY = 0) {
61811
61844
  this.sheetViewHeight = height;
@@ -61815,7 +61848,7 @@ class SheetViewPlugin extends UIPlugin {
61815
61848
  this.recomputeViewports();
61816
61849
  }
61817
61850
  recomputeViewports() {
61818
- for (let sheetId of Object.keys(this.viewports)) {
61851
+ for (const sheetId of this.getters.getSheetIds()) {
61819
61852
  this.resetViewports(sheetId);
61820
61853
  }
61821
61854
  }
@@ -61837,8 +61870,10 @@ class SheetViewPlugin extends UIPlugin {
61837
61870
  const { xSplit, ySplit } = this.getters.getPaneDivisions(sheetId);
61838
61871
  const nCols = this.getters.getNumberCols(sheetId);
61839
61872
  const nRows = this.getters.getNumberRows(sheetId);
61840
- const colOffset = this.getters.getColRowOffset("COL", 0, xSplit, sheetId);
61841
- const rowOffset = this.getters.getColRowOffset("ROW", 0, ySplit, sheetId);
61873
+ const colOffset = Math.min(this.getters.getColRowOffset("COL", 0, xSplit, sheetId), this.sheetViewWidth);
61874
+ const rowOffset = Math.min(this.getters.getColRowOffset("ROW", 0, ySplit, sheetId), this.sheetViewHeight);
61875
+ const unfrozenWidth = Math.max(this.sheetViewWidth - colOffset, 0);
61876
+ const unfrozenHeight = Math.max(this.sheetViewHeight - rowOffset, 0);
61842
61877
  const { xRatio, yRatio } = this.getFrozenSheetViewRatio(sheetId);
61843
61878
  const canScrollHorizontally = xRatio < 1.0;
61844
61879
  const canScrollVertically = yRatio < 1.0;
@@ -61849,14 +61884,14 @@ class SheetViewPlugin extends UIPlugin {
61849
61884
  new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: 0, bottom: ySplit - 1 }, { width: colOffset, height: rowOffset }, { canScrollHorizontally: false, canScrollVertically: false }, { x: 0, y: 0 })) ||
61850
61885
  undefined,
61851
61886
  topRight: (ySplit &&
61852
- new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: 0, bottom: ySplit - 1 }, { width: this.sheetViewWidth - colOffset, height: rowOffset }, { canScrollHorizontally, canScrollVertically: false }, { x: canScrollHorizontally ? previousOffset.x : 0, y: 0 })) ||
61887
+ new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: 0, bottom: ySplit - 1 }, { width: unfrozenWidth, height: rowOffset }, { canScrollHorizontally, canScrollVertically: false }, { x: canScrollHorizontally ? previousOffset.x : 0, y: 0 })) ||
61853
61888
  undefined,
61854
61889
  bottomLeft: (xSplit &&
61855
- new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: ySplit, bottom: nRows - 1 }, { width: colOffset, height: this.sheetViewHeight - rowOffset }, { canScrollHorizontally: false, canScrollVertically }, { x: 0, y: canScrollVertically ? previousOffset.y : 0 })) ||
61890
+ new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: ySplit, bottom: nRows - 1 }, { width: colOffset, height: unfrozenHeight }, { canScrollHorizontally: false, canScrollVertically }, { x: 0, y: canScrollVertically ? previousOffset.y : 0 })) ||
61856
61891
  undefined,
61857
61892
  bottomRight: new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: ySplit, bottom: nRows - 1 }, {
61858
- width: this.sheetViewWidth - colOffset,
61859
- height: this.sheetViewHeight - rowOffset,
61893
+ width: unfrozenWidth,
61894
+ height: unfrozenHeight,
61860
61895
  }, { canScrollHorizontally, canScrollVertically }, {
61861
61896
  x: canScrollHorizontally ? previousOffset.x : 0,
61862
61897
  y: canScrollVertically ? previousOffset.y : 0,
@@ -61933,12 +61968,26 @@ class SheetViewPlugin extends UIPlugin {
61933
61968
  const height = this.sheetViewHeight + this.gridOffsetY;
61934
61969
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
61935
61970
  }
61936
- recomposeRect(viewportRects) {
61937
- const x = Math.min(...viewportRects.map((rect) => rect.x));
61938
- const y = Math.min(...viewportRects.map((rect) => rect.y));
61939
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
61940
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
61941
- return { x, y, width, height };
61971
+ mapViewportsToRect(sheetId, rectCallBack) {
61972
+ let x = Infinity;
61973
+ let y = Infinity;
61974
+ let width = 0;
61975
+ let height = 0;
61976
+ let hasViewports = false;
61977
+ for (const viewport of this.getSubViewports(sheetId)) {
61978
+ const rect = rectCallBack(viewport);
61979
+ if (rect) {
61980
+ hasViewports = true;
61981
+ x = Math.min(x, rect.x);
61982
+ y = Math.min(y, rect.y);
61983
+ width = Math.max(width, rect.x + rect.width);
61984
+ height = Math.max(height, rect.y + rect.height);
61985
+ }
61986
+ }
61987
+ if (!hasViewports) {
61988
+ return { x: 0, y: 0, width: 0, height: 0 };
61989
+ }
61990
+ return { x, y, width: width - x, height: height - y };
61942
61991
  }
61943
61992
  }
61944
61993
 
@@ -62909,7 +62958,7 @@ class BottomBar extends Component {
62909
62958
  draggedItemId: sheetId,
62910
62959
  initialMousePosition: event.clientX,
62911
62960
  items: sheets,
62912
- containerEl: this.sheetListRef.el,
62961
+ scrollableContainerEl: this.sheetListRef.el,
62913
62962
  onDragEnd: (sheetId, finalIndex) => this.onDragEnd(sheetId, finalIndex),
62914
62963
  });
62915
62964
  }
@@ -68828,6 +68877,6 @@ const constants = {
68828
68877
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, 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 };
68829
68878
 
68830
68879
 
68831
- __info__.version = "17.4.20";
68832
- __info__.date = "2025-01-31T08:00:07.103Z";
68833
- __info__.hash = "54a344a";
68880
+ __info__.version = "17.4.22";
68881
+ __info__.date = "2025-02-10T09:14:48.889Z";
68882
+ __info__.hash = "667f2b1";