@odoo/o-spreadsheet 17.0.47 → 17.0.49
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.
- package/dist/o-spreadsheet.cjs.js +170 -126
- package/dist/o-spreadsheet.d.ts +11 -14
- package/dist/o-spreadsheet.esm.js +170 -126
- package/dist/o-spreadsheet.iife.js +170 -126
- package/dist/o-spreadsheet.iife.min.js +197 -197
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -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.
|
|
6
|
-
* @date 2025-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.49
|
|
6
|
+
* @date 2025-02-10T08:55:47.771Z
|
|
7
|
+
* @hash 1049319
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
(function (exports, owl) {
|
|
@@ -687,9 +687,16 @@
|
|
|
687
687
|
}
|
|
688
688
|
return true;
|
|
689
689
|
}
|
|
690
|
-
/**
|
|
690
|
+
/**
|
|
691
|
+
* Check if the given array contains all the values of the other array.
|
|
692
|
+
* It makes the assumption that both array do not contain duplicates.
|
|
693
|
+
*/
|
|
691
694
|
function includesAll(arr, values) {
|
|
692
|
-
|
|
695
|
+
if (arr.length < values.length) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
const set = new Set(arr);
|
|
699
|
+
return values.every((value) => set.has(value));
|
|
693
700
|
}
|
|
694
701
|
/**
|
|
695
702
|
* Return an object with all the keys in the object that have a falsy value removed.
|
|
@@ -18558,20 +18565,21 @@
|
|
|
18558
18565
|
description: _t("Horizontal lookup"),
|
|
18559
18566
|
args: [
|
|
18560
18567
|
arg("search_key (any)", _t("The value to search for. For example, 42, 'Cats', or I24.")),
|
|
18561
|
-
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.")),
|
|
18568
|
+
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.")),
|
|
18562
18569
|
arg("index (number)", _t("The row index of the value to be returned, where the first row in range is numbered 1.")),
|
|
18563
18570
|
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.")),
|
|
18564
18571
|
],
|
|
18565
18572
|
returns: ["ANY"],
|
|
18566
18573
|
computeValueAndFormat: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18567
18574
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18568
|
-
|
|
18575
|
+
const _range = toMatrix(range);
|
|
18576
|
+
assert(() => 1 <= _index && _index <= _range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
18569
18577
|
const getValueFromRange = (range, index) => range[index][0].value;
|
|
18570
18578
|
const _isSorted = toBoolean(isSorted.value);
|
|
18571
18579
|
const colIndex = _isSorted
|
|
18572
|
-
? dichotomicSearch(
|
|
18573
|
-
: linearSearch(
|
|
18574
|
-
const col =
|
|
18580
|
+
? dichotomicSearch(_range, searchKey?.value, "nextSmaller", "asc", _range.length, getValueFromRange)
|
|
18581
|
+
: linearSearch(_range, searchKey?.value, "strict", _range.length, getValueFromRange);
|
|
18582
|
+
const col = _range[colIndex];
|
|
18575
18583
|
assertAvailable(col, searchKey?.value);
|
|
18576
18584
|
return col[_index - 1];
|
|
18577
18585
|
},
|
|
@@ -18616,36 +18624,38 @@
|
|
|
18616
18624
|
description: _t("Look up a value."),
|
|
18617
18625
|
args: [
|
|
18618
18626
|
arg("search_key (any)", _t("The value to search for. For example, 42, 'Cats', or I24.")),
|
|
18619
|
-
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.")),
|
|
18620
|
-
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.")),
|
|
18627
|
+
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.")),
|
|
18628
|
+
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.")),
|
|
18621
18629
|
],
|
|
18622
18630
|
returns: ["ANY"],
|
|
18623
18631
|
computeValueAndFormat: function (searchKey, searchArray, resultRange) {
|
|
18624
|
-
|
|
18625
|
-
|
|
18632
|
+
const _searchArray = toMatrix(searchArray);
|
|
18633
|
+
const _resultRange = toMatrix(resultRange);
|
|
18634
|
+
let nbCol = _searchArray.length;
|
|
18635
|
+
let nbRow = _searchArray[0].length;
|
|
18626
18636
|
const verticalSearch = nbRow >= nbCol;
|
|
18627
18637
|
const getElement = verticalSearch
|
|
18628
18638
|
? (range, index) => range[0][index].value
|
|
18629
18639
|
: (range, index) => range[index][0].value;
|
|
18630
18640
|
const rangeLength = verticalSearch ? nbRow : nbCol;
|
|
18631
|
-
const index = dichotomicSearch(
|
|
18641
|
+
const index = dichotomicSearch(_searchArray, searchKey?.value, "nextSmaller", "asc", rangeLength, getElement);
|
|
18632
18642
|
if (index === -1)
|
|
18633
18643
|
assertAvailable(undefined, searchKey?.value);
|
|
18634
18644
|
verticalSearch
|
|
18635
|
-
? assertAvailable(
|
|
18636
|
-
: assertAvailable(
|
|
18637
|
-
if (
|
|
18638
|
-
return verticalSearch ?
|
|
18645
|
+
? assertAvailable(_searchArray[0][index], searchKey?.value)
|
|
18646
|
+
: assertAvailable(_searchArray[index][nbRow - 1], searchKey?.value);
|
|
18647
|
+
if (_resultRange[0].length === 0) {
|
|
18648
|
+
return verticalSearch ? _searchArray[nbCol - 1][index] : _searchArray[index][nbRow - 1];
|
|
18639
18649
|
}
|
|
18640
|
-
nbCol =
|
|
18641
|
-
nbRow =
|
|
18650
|
+
nbCol = _resultRange.length;
|
|
18651
|
+
nbRow = _resultRange[0].length;
|
|
18642
18652
|
assert(() => nbCol === 1 || nbRow === 1, _t("The result_range must be a single row or a single column."));
|
|
18643
18653
|
if (nbCol > 1) {
|
|
18644
18654
|
assert(() => index <= nbCol - 1, _t("[[FUNCTION_NAME]] evaluates to an out of range row value %s.", (index + 1).toString()));
|
|
18645
|
-
return
|
|
18655
|
+
return _resultRange[index][0];
|
|
18646
18656
|
}
|
|
18647
18657
|
assert(() => index <= nbRow - 1, _t("[[FUNCTION_NAME]] evaluates to an out of range column value %s.", (index + 1).toString()));
|
|
18648
|
-
return
|
|
18658
|
+
return _resultRange[0][index];
|
|
18649
18659
|
},
|
|
18650
18660
|
isExported: true,
|
|
18651
18661
|
};
|
|
@@ -18663,27 +18673,28 @@
|
|
|
18663
18673
|
returns: ["NUMBER"],
|
|
18664
18674
|
compute: function (searchKey, range, searchType = DEFAULT_SEARCH_TYPE) {
|
|
18665
18675
|
let _searchType = toNumber(searchType, this.locale);
|
|
18666
|
-
const
|
|
18667
|
-
const
|
|
18676
|
+
const _range = toMatrix(range);
|
|
18677
|
+
const nbCol = _range.length;
|
|
18678
|
+
const nbRow = _range[0].length;
|
|
18668
18679
|
assert(() => nbCol === 1 || nbRow === 1, _t("The range must be a single row or a single column."));
|
|
18669
18680
|
let index = -1;
|
|
18670
18681
|
const getElement = nbCol === 1
|
|
18671
|
-
? (
|
|
18672
|
-
: (
|
|
18673
|
-
const rangeLen = nbCol === 1 ?
|
|
18682
|
+
? (_range, index) => _range[0][index]
|
|
18683
|
+
: (_range, index) => _range[index][0];
|
|
18684
|
+
const rangeLen = nbCol === 1 ? _range[0].length : _range.length;
|
|
18674
18685
|
_searchType = Math.sign(_searchType);
|
|
18675
18686
|
switch (_searchType) {
|
|
18676
18687
|
case 1:
|
|
18677
|
-
index = dichotomicSearch(
|
|
18688
|
+
index = dichotomicSearch(_range, searchKey, "nextSmaller", "asc", rangeLen, getElement);
|
|
18678
18689
|
break;
|
|
18679
18690
|
case 0:
|
|
18680
|
-
index = linearSearch(
|
|
18691
|
+
index = linearSearch(_range, searchKey, "strict", rangeLen, getElement);
|
|
18681
18692
|
break;
|
|
18682
18693
|
case -1:
|
|
18683
|
-
index = dichotomicSearch(
|
|
18694
|
+
index = dichotomicSearch(_range, searchKey, "nextGreater", "desc", rangeLen, getElement);
|
|
18684
18695
|
break;
|
|
18685
18696
|
}
|
|
18686
|
-
assertAvailable(nbCol === 1 ?
|
|
18697
|
+
assertAvailable(nbCol === 1 ? _range[0][index] : _range[index], searchKey);
|
|
18687
18698
|
return index + 1;
|
|
18688
18699
|
},
|
|
18689
18700
|
isExported: true,
|
|
@@ -18732,13 +18743,14 @@
|
|
|
18732
18743
|
returns: ["ANY"],
|
|
18733
18744
|
computeValueAndFormat: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18734
18745
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18735
|
-
|
|
18746
|
+
const _range = toMatrix(range);
|
|
18747
|
+
assert(() => 1 <= _index && _index <= _range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
18736
18748
|
const getValueFromRange = (range, index) => range[0][index].value;
|
|
18737
18749
|
const _isSorted = toBoolean(isSorted.value);
|
|
18738
18750
|
const rowIndex = _isSorted
|
|
18739
|
-
? dichotomicSearch(
|
|
18740
|
-
: linearSearch(
|
|
18741
|
-
const value =
|
|
18751
|
+
? dichotomicSearch(_range, searchKey?.value, "nextSmaller", "asc", _range[0].length, getValueFromRange)
|
|
18752
|
+
: linearSearch(_range, searchKey?.value, "strict", _range[0].length, getValueFromRange);
|
|
18753
|
+
const value = _range[_index - 1][rowIndex];
|
|
18742
18754
|
assertAvailable(value, searchKey?.value);
|
|
18743
18755
|
return value;
|
|
18744
18756
|
},
|
|
@@ -18765,26 +18777,28 @@
|
|
|
18765
18777
|
computeValueAndFormat: function (searchKey, lookupRange, returnRange, defaultValue, matchMode = { value: DEFAULT_MATCH_MODE }, searchMode = { value: DEFAULT_SEARCH_MODE }) {
|
|
18766
18778
|
const _matchMode = Math.trunc(toNumber(matchMode.value, this.locale));
|
|
18767
18779
|
const _searchMode = Math.trunc(toNumber(searchMode.value, this.locale));
|
|
18768
|
-
|
|
18780
|
+
const _lookupRange = toMatrix(lookupRange);
|
|
18781
|
+
const _returnRange = toMatrix(returnRange);
|
|
18782
|
+
assert(() => _lookupRange.length === 1 || _lookupRange[0].length === 1, _t("lookup_range should be either a single row or single column."));
|
|
18769
18783
|
assert(() => [-1, 1, -2, 2].includes(_searchMode), _t("searchMode should be a value in [-1, 1, -2, 2]."));
|
|
18770
18784
|
assert(() => [-1, 0, 1].includes(_matchMode), _t("matchMode should be a value in [-1, 0, 1]."));
|
|
18771
|
-
const lookupDirection =
|
|
18785
|
+
const lookupDirection = _lookupRange.length === 1 ? "col" : "row";
|
|
18772
18786
|
assert(() => lookupDirection === "col"
|
|
18773
|
-
?
|
|
18774
|
-
:
|
|
18787
|
+
? _returnRange[0].length === _lookupRange[0].length
|
|
18788
|
+
: _returnRange.length === _lookupRange.length, _t("return_range should have the same dimensions as lookup_range."));
|
|
18775
18789
|
const getElement = lookupDirection === "col"
|
|
18776
18790
|
? (range, index) => range[0][index].value
|
|
18777
18791
|
: (range, index) => range[index][0].value;
|
|
18778
|
-
const rangeLen = lookupDirection === "col" ?
|
|
18792
|
+
const rangeLen = lookupDirection === "col" ? _lookupRange[0].length : _lookupRange.length;
|
|
18779
18793
|
const mode = _matchMode === 0 ? "strict" : _matchMode === 1 ? "nextGreater" : "nextSmaller";
|
|
18780
18794
|
const reverseSearch = _searchMode === -1;
|
|
18781
18795
|
const index = _searchMode === 2 || _searchMode === -2
|
|
18782
|
-
? dichotomicSearch(
|
|
18783
|
-
: linearSearch(
|
|
18796
|
+
? dichotomicSearch(_lookupRange, searchKey?.value, mode, _searchMode === 2 ? "asc" : "desc", rangeLen, getElement)
|
|
18797
|
+
: linearSearch(_lookupRange, searchKey?.value, mode, rangeLen, getElement, reverseSearch);
|
|
18784
18798
|
if (index !== -1) {
|
|
18785
18799
|
return lookupDirection === "col"
|
|
18786
|
-
?
|
|
18787
|
-
: [
|
|
18800
|
+
? _returnRange.map((col) => [col[index]])
|
|
18801
|
+
: [_returnRange[index]];
|
|
18788
18802
|
}
|
|
18789
18803
|
const _defaultValue = defaultValue?.();
|
|
18790
18804
|
assertAvailable(_defaultValue, searchKey?.value);
|
|
@@ -29242,6 +29256,9 @@
|
|
|
29242
29256
|
canvas.width = width * dpr;
|
|
29243
29257
|
canvas.height = height * dpr;
|
|
29244
29258
|
canvas.setAttribute("style", `width:${width}px;height:${height}px;`);
|
|
29259
|
+
if (width === 0 || height === 0) {
|
|
29260
|
+
return;
|
|
29261
|
+
}
|
|
29245
29262
|
// Imagine each pixel as a large square. The whole-number coordinates (0, 1, 2…)
|
|
29246
29263
|
// are the edges of the squares. If you draw a one-unit-wide line between whole-number
|
|
29247
29264
|
// coordinates, it will overlap opposite sides of the pixel square, and the resulting
|
|
@@ -34722,7 +34739,7 @@
|
|
|
34722
34739
|
getCommonSides(border1, border2) {
|
|
34723
34740
|
const commonBorder = {};
|
|
34724
34741
|
for (let side of ["top", "bottom", "left", "right"]) {
|
|
34725
|
-
if (border1[side] && border1[side]
|
|
34742
|
+
if (border1[side] && deepEquals(border1[side], border2[side])) {
|
|
34726
34743
|
commonBorder[side] = border1[side];
|
|
34727
34744
|
}
|
|
34728
34745
|
}
|
|
@@ -46268,11 +46285,10 @@
|
|
|
46268
46285
|
switch (layer) {
|
|
46269
46286
|
case 0 /* LAYERS.Background */:
|
|
46270
46287
|
this.drawGlobalBackground(renderingContext);
|
|
46271
|
-
for (const zone of this.getters.
|
|
46288
|
+
for (const { zone, rect } of this.getters.getAllActiveViewportsZonesAndRect()) {
|
|
46272
46289
|
const { ctx } = renderingContext;
|
|
46273
46290
|
ctx.save();
|
|
46274
46291
|
ctx.beginPath();
|
|
46275
|
-
const rect = this.getters.getVisibleRect(zone);
|
|
46276
46292
|
ctx.rect(rect.x, rect.y, rect.width, rect.height);
|
|
46277
46293
|
ctx.clip();
|
|
46278
46294
|
this.boxes = this.getGridBoxes(zone);
|
|
@@ -46542,10 +46558,8 @@
|
|
|
46542
46558
|
const { ctx, thinLineWidth } = renderingContext;
|
|
46543
46559
|
const visibleCols = this.getters.getSheetViewVisibleCols();
|
|
46544
46560
|
const left = visibleCols[0];
|
|
46545
|
-
const right = visibleCols[visibleCols.length - 1];
|
|
46546
46561
|
const visibleRows = this.getters.getSheetViewVisibleRows();
|
|
46547
46562
|
const top = visibleRows[0];
|
|
46548
|
-
const bottom = visibleRows[visibleRows.length - 1];
|
|
46549
46563
|
const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
|
|
46550
46564
|
const selection = this.getters.getSelectedZones();
|
|
46551
46565
|
const selectedCols = getZonesCols(selection);
|
|
@@ -46561,7 +46575,7 @@
|
|
|
46561
46575
|
ctx.lineWidth = thinLineWidth;
|
|
46562
46576
|
ctx.strokeStyle = "#333";
|
|
46563
46577
|
// Columns headers background
|
|
46564
|
-
for (
|
|
46578
|
+
for (const col of visibleCols) {
|
|
46565
46579
|
const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 };
|
|
46566
46580
|
const { x, width } = this.getters.getVisibleRect(colZone);
|
|
46567
46581
|
const colHasFilter = this.getters.doesZonesContainFilter(sheetId, [colZone]);
|
|
@@ -46581,7 +46595,7 @@
|
|
|
46581
46595
|
ctx.fillRect(x, 0, width, HEADER_HEIGHT);
|
|
46582
46596
|
}
|
|
46583
46597
|
// Rows headers background
|
|
46584
|
-
for (
|
|
46598
|
+
for (const row of visibleRows) {
|
|
46585
46599
|
const rowZone = { top: row, bottom: row, left: 0, right: numberOfCols - 1 };
|
|
46586
46600
|
const { y, height } = this.getters.getVisibleRect(rowZone);
|
|
46587
46601
|
const rowHasFilter = this.getters.doesZonesContainFilter(sheetId, [rowZone]);
|
|
@@ -46610,21 +46624,21 @@
|
|
|
46610
46624
|
ctx.stroke();
|
|
46611
46625
|
ctx.beginPath();
|
|
46612
46626
|
// column text + separator
|
|
46613
|
-
for (const
|
|
46614
|
-
const colSize = this.getters.getColSize(sheetId,
|
|
46615
|
-
const colName = numberToLetters(
|
|
46616
|
-
ctx.fillStyle = activeCols.has(
|
|
46617
|
-
let colStart = this.getHeaderOffset("COL", left,
|
|
46627
|
+
for (const col of visibleCols) {
|
|
46628
|
+
const colSize = this.getters.getColSize(sheetId, col);
|
|
46629
|
+
const colName = numberToLetters(col);
|
|
46630
|
+
ctx.fillStyle = activeCols.has(col) ? "#fff" : TEXT_HEADER_COLOR;
|
|
46631
|
+
let colStart = this.getHeaderOffset("COL", left, col);
|
|
46618
46632
|
ctx.fillText(colName, colStart + colSize / 2, HEADER_HEIGHT / 2);
|
|
46619
46633
|
ctx.moveTo(colStart + colSize, 0);
|
|
46620
46634
|
ctx.lineTo(colStart + colSize, HEADER_HEIGHT);
|
|
46621
46635
|
}
|
|
46622
46636
|
// row text + separator
|
|
46623
|
-
for (const
|
|
46624
|
-
const rowSize = this.getters.getRowSize(sheetId,
|
|
46625
|
-
ctx.fillStyle = activeRows.has(
|
|
46626
|
-
let rowStart = this.getHeaderOffset("ROW", top,
|
|
46627
|
-
ctx.fillText(String(
|
|
46637
|
+
for (const row of visibleRows) {
|
|
46638
|
+
const rowSize = this.getters.getRowSize(sheetId, row);
|
|
46639
|
+
ctx.fillStyle = activeRows.has(row) ? "#fff" : TEXT_HEADER_COLOR;
|
|
46640
|
+
let rowStart = this.getHeaderOffset("ROW", top, row);
|
|
46641
|
+
ctx.fillText(String(row + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
|
|
46628
46642
|
ctx.moveTo(0, rowStart + rowSize);
|
|
46629
46643
|
ctx.lineTo(HEADER_WIDTH, rowStart + rowSize);
|
|
46630
46644
|
}
|
|
@@ -50515,8 +50529,17 @@
|
|
|
50515
50529
|
this.getters = getters;
|
|
50516
50530
|
this.sheetId = sheetId;
|
|
50517
50531
|
this.boundaries = boundaries;
|
|
50518
|
-
|
|
50519
|
-
|
|
50532
|
+
if (sizeInGrid.width < 0 || sizeInGrid.height < 0) {
|
|
50533
|
+
throw new Error("Viewport size cannot be negative");
|
|
50534
|
+
}
|
|
50535
|
+
this.viewportWidth = sizeInGrid.height && sizeInGrid.width;
|
|
50536
|
+
this.viewportHeight = sizeInGrid.width && sizeInGrid.height;
|
|
50537
|
+
this.top = boundaries.top;
|
|
50538
|
+
this.bottom = boundaries.bottom;
|
|
50539
|
+
this.left = boundaries.left;
|
|
50540
|
+
this.right = boundaries.right;
|
|
50541
|
+
this.offsetX = offsets.x;
|
|
50542
|
+
this.offsetY = offsets.y;
|
|
50520
50543
|
this.offsetScrollbarX = offsets.x;
|
|
50521
50544
|
this.offsetScrollbarY = offsets.y;
|
|
50522
50545
|
this.canScrollVertically = options.canScrollVertically;
|
|
@@ -50559,9 +50582,9 @@
|
|
|
50559
50582
|
Math.min(topRowSize, this.viewportHeight - lastRowSize) // Add pixels that allows the snapping at maximum vertical scroll
|
|
50560
50583
|
);
|
|
50561
50584
|
height = Math.max(height, this.viewportHeight); // if the viewport grid size is smaller than its client height, return client height
|
|
50562
|
-
|
|
50563
|
-
|
|
50564
|
-
|
|
50585
|
+
if (lastRowEnd + FOOTER_HEIGHT > height && !this.getters.isReadonly()) {
|
|
50586
|
+
height += FOOTER_HEIGHT;
|
|
50587
|
+
}
|
|
50565
50588
|
}
|
|
50566
50589
|
return { width, height };
|
|
50567
50590
|
}
|
|
@@ -50708,6 +50731,9 @@
|
|
|
50708
50731
|
}
|
|
50709
50732
|
// PRIVATE
|
|
50710
50733
|
searchHeaderIndex(dimension, position, startIndex = 0) {
|
|
50734
|
+
if (this.viewportWidth <= 0 || this.viewportHeight <= 0) {
|
|
50735
|
+
return -1;
|
|
50736
|
+
}
|
|
50711
50737
|
const sheetId = this.sheetId;
|
|
50712
50738
|
const headers = this.getters.getNumberHeaders(sheetId, dimension);
|
|
50713
50739
|
// using a binary search:
|
|
@@ -50747,7 +50773,7 @@
|
|
|
50747
50773
|
this.adjustViewportZoneY();
|
|
50748
50774
|
}
|
|
50749
50775
|
/** Corrects the viewport's horizontal offset based on the current structure
|
|
50750
|
-
* To make sure that at least
|
|
50776
|
+
* To make sure that at least one column is visible inside the viewport.
|
|
50751
50777
|
*/
|
|
50752
50778
|
adjustViewportOffsetX() {
|
|
50753
50779
|
if (this.canScrollHorizontally) {
|
|
@@ -50764,7 +50790,7 @@
|
|
|
50764
50790
|
this.adjustViewportZoneX();
|
|
50765
50791
|
}
|
|
50766
50792
|
/** Corrects the viewport's vertical offset based on the current structure
|
|
50767
|
-
* To make sure that at least
|
|
50793
|
+
* To make sure that at least one row is visible inside the viewport.
|
|
50768
50794
|
*/
|
|
50769
50795
|
adjustViewportOffsetY() {
|
|
50770
50796
|
if (this.canScrollVertically) {
|
|
@@ -50786,11 +50812,14 @@
|
|
|
50786
50812
|
const sheetId = this.sheetId;
|
|
50787
50813
|
this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
|
|
50788
50814
|
this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
|
|
50815
|
+
if (!this.viewportWidth) {
|
|
50816
|
+
return;
|
|
50817
|
+
}
|
|
50789
50818
|
if (this.left === -1) {
|
|
50790
50819
|
this.left = this.boundaries.left;
|
|
50791
50820
|
}
|
|
50792
50821
|
if (this.right === -1) {
|
|
50793
|
-
this.right = this.
|
|
50822
|
+
this.right = this.boundaries.right;
|
|
50794
50823
|
}
|
|
50795
50824
|
this.offsetX =
|
|
50796
50825
|
this.getters.getColDimensions(sheetId, this.left).start -
|
|
@@ -50802,11 +50831,14 @@
|
|
|
50802
50831
|
const sheetId = this.sheetId;
|
|
50803
50832
|
this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
|
|
50804
50833
|
this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
|
|
50834
|
+
if (!this.viewportHeight) {
|
|
50835
|
+
return;
|
|
50836
|
+
}
|
|
50805
50837
|
if (this.top === -1) {
|
|
50806
50838
|
this.top = this.boundaries.top;
|
|
50807
50839
|
}
|
|
50808
50840
|
if (this.bottom === -1) {
|
|
50809
|
-
this.bottom = this.
|
|
50841
|
+
this.bottom = this.boundaries.bottom;
|
|
50810
50842
|
}
|
|
50811
50843
|
this.offsetY =
|
|
50812
50844
|
this.getters.getRowDimensions(sheetId, this.top).start -
|
|
@@ -50878,7 +50910,7 @@
|
|
|
50878
50910
|
"getSheetViewVisibleRows",
|
|
50879
50911
|
"getFrozenSheetViewRatio",
|
|
50880
50912
|
"isPositionVisible",
|
|
50881
|
-
"
|
|
50913
|
+
"getAllActiveViewportsZonesAndRect",
|
|
50882
50914
|
"getRect",
|
|
50883
50915
|
];
|
|
50884
50916
|
viewports = {};
|
|
@@ -51112,12 +51144,12 @@
|
|
|
51112
51144
|
const sheetId = this.getters.getActiveSheetId();
|
|
51113
51145
|
const viewports = this.getSubViewports(sheetId);
|
|
51114
51146
|
//TODO ake another commit to eimprove this
|
|
51115
|
-
return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => !this.getters.isHeaderHidden(sheetId, "COL", col));
|
|
51147
|
+
return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => col >= 0 && !this.getters.isHeaderHidden(sheetId, "COL", col));
|
|
51116
51148
|
}
|
|
51117
51149
|
getSheetViewVisibleRows() {
|
|
51118
51150
|
const sheetId = this.getters.getActiveSheetId();
|
|
51119
51151
|
const viewports = this.getSubViewports(sheetId);
|
|
51120
|
-
return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => !this.getters.isHeaderHidden(sheetId, "ROW", row));
|
|
51152
|
+
return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => row >= 0 && !this.getters.isHeaderHidden(sheetId, "ROW", row));
|
|
51121
51153
|
}
|
|
51122
51154
|
/**
|
|
51123
51155
|
* Get the positions of all the cells that are visible in the viewport, taking merges into account.
|
|
@@ -51160,19 +51192,19 @@
|
|
|
51160
51192
|
maxOffsetY: Math.max(0, height - viewport.viewportHeight + 1),
|
|
51161
51193
|
};
|
|
51162
51194
|
}
|
|
51163
|
-
getColRowOffsetInViewport(dimension,
|
|
51164
|
-
|
|
51165
|
-
|
|
51166
|
-
const visibleRows = this.getters.getSheetViewVisibleRows();
|
|
51167
|
-
if (index < referenceIndex) {
|
|
51168
|
-
return -this.getColRowOffsetInViewport(dimension, index, referenceIndex);
|
|
51195
|
+
getColRowOffsetInViewport(dimension, referenceHeaderIndex, targetHeaderIndex) {
|
|
51196
|
+
if (targetHeaderIndex < referenceHeaderIndex) {
|
|
51197
|
+
return -this.getColRowOffsetInViewport(dimension, targetHeaderIndex, referenceHeaderIndex);
|
|
51169
51198
|
}
|
|
51199
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
51200
|
+
const visibleHeaders = dimension === "COL"
|
|
51201
|
+
? this.getters.getSheetViewVisibleCols()
|
|
51202
|
+
: this.getters.getSheetViewVisibleRows();
|
|
51203
|
+
const startIndex = visibleHeaders.findIndex((header) => referenceHeaderIndex >= header);
|
|
51204
|
+
const endIndex = visibleHeaders.findIndex((header) => targetHeaderIndex <= header);
|
|
51205
|
+
const relevantIndexes = visibleHeaders.slice(startIndex, endIndex);
|
|
51170
51206
|
let offset = 0;
|
|
51171
|
-
const
|
|
51172
|
-
for (let i = referenceIndex; i < index; i++) {
|
|
51173
|
-
if (!visibleIndexes.includes(i)) {
|
|
51174
|
-
continue;
|
|
51175
|
-
}
|
|
51207
|
+
for (const i of relevantIndexes) {
|
|
51176
51208
|
offset += this.getters.getHeaderSize(sheetId, dimension, i);
|
|
51177
51209
|
}
|
|
51178
51210
|
return offset;
|
|
@@ -51219,7 +51251,7 @@
|
|
|
51219
51251
|
}
|
|
51220
51252
|
return { canEdgeScroll, direction, delay };
|
|
51221
51253
|
}
|
|
51222
|
-
getEdgeScrollRow(y, previousY,
|
|
51254
|
+
getEdgeScrollRow(y, previousY, startingY) {
|
|
51223
51255
|
let canEdgeScroll = false;
|
|
51224
51256
|
let direction = 0;
|
|
51225
51257
|
let delay = 0;
|
|
@@ -51240,7 +51272,7 @@
|
|
|
51240
51272
|
delay = scrollDelay(y - height);
|
|
51241
51273
|
direction = 1;
|
|
51242
51274
|
}
|
|
51243
|
-
else if (y < offsetCorrectionY &&
|
|
51275
|
+
else if (y < offsetCorrectionY && startingY >= offsetCorrectionY && currentOffsetY > 0) {
|
|
51244
51276
|
// 2
|
|
51245
51277
|
canEdgeScroll = true;
|
|
51246
51278
|
delay = scrollDelay(offsetCorrectionY - y);
|
|
@@ -51266,13 +51298,7 @@
|
|
|
51266
51298
|
*/
|
|
51267
51299
|
getVisibleRectWithoutHeaders(zone) {
|
|
51268
51300
|
const sheetId = this.getters.getActiveSheetId();
|
|
51269
|
-
|
|
51270
|
-
.map((viewport) => viewport.getVisibleRect(zone))
|
|
51271
|
-
.filter(isDefined$1);
|
|
51272
|
-
if (viewportRects.length === 0) {
|
|
51273
|
-
return { x: 0, y: 0, width: 0, height: 0 };
|
|
51274
|
-
}
|
|
51275
|
-
return this.recomposeRect(viewportRects);
|
|
51301
|
+
return this.mapViewportsToRect(sheetId, (viewport) => viewport.getVisibleRect(zone));
|
|
51276
51302
|
}
|
|
51277
51303
|
/**
|
|
51278
51304
|
* Computes the actual size and position (:Rect) of the zone on the canvas
|
|
@@ -51280,13 +51306,7 @@
|
|
|
51280
51306
|
*/
|
|
51281
51307
|
getRect(zone) {
|
|
51282
51308
|
const sheetId = this.getters.getActiveSheetId();
|
|
51283
|
-
const
|
|
51284
|
-
.map((viewport) => viewport.getFullRect(zone))
|
|
51285
|
-
.filter(isDefined$1);
|
|
51286
|
-
if (viewportRects.length === 0) {
|
|
51287
|
-
return { x: 0, y: 0, width: 0, height: 0 };
|
|
51288
|
-
}
|
|
51289
|
-
const rect = this.recomposeRect(viewportRects);
|
|
51309
|
+
const rect = this.mapViewportsToRect(sheetId, (viewport) => viewport.getFullRect(zone));
|
|
51290
51310
|
return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
|
|
51291
51311
|
}
|
|
51292
51312
|
/**
|
|
@@ -51301,9 +51321,18 @@
|
|
|
51301
51321
|
const y = this.getters.getRowDimensions(sheetId, ySplit).start;
|
|
51302
51322
|
return { x, y };
|
|
51303
51323
|
}
|
|
51304
|
-
|
|
51324
|
+
getAllActiveViewportsZonesAndRect() {
|
|
51305
51325
|
const sheetId = this.getters.getActiveSheetId();
|
|
51306
|
-
return this.getSubViewports(sheetId)
|
|
51326
|
+
return this.getSubViewports(sheetId).map((viewport) => {
|
|
51327
|
+
return {
|
|
51328
|
+
zone: viewport,
|
|
51329
|
+
rect: {
|
|
51330
|
+
x: viewport.offsetCorrectionX + this.gridOffsetX,
|
|
51331
|
+
y: viewport.offsetCorrectionY + this.gridOffsetY,
|
|
51332
|
+
...viewport.getMaxSize(),
|
|
51333
|
+
},
|
|
51334
|
+
};
|
|
51335
|
+
});
|
|
51307
51336
|
}
|
|
51308
51337
|
// ---------------------------------------------------------------------------
|
|
51309
51338
|
// Private
|
|
@@ -51356,12 +51385,11 @@
|
|
|
51356
51385
|
}
|
|
51357
51386
|
/** gets rid of deprecated sheetIds */
|
|
51358
51387
|
cleanViewports() {
|
|
51359
|
-
const
|
|
51360
|
-
for (
|
|
51361
|
-
|
|
51362
|
-
delete this.viewports[sheetId];
|
|
51363
|
-
}
|
|
51388
|
+
const newViewport = {};
|
|
51389
|
+
for (const sheetId of this.getters.getSheetIds()) {
|
|
51390
|
+
newViewport[sheetId] = this.viewports[sheetId];
|
|
51364
51391
|
}
|
|
51392
|
+
this.viewports = newViewport;
|
|
51365
51393
|
}
|
|
51366
51394
|
resizeSheetView(height, width, gridOffsetX = 0, gridOffsetY = 0) {
|
|
51367
51395
|
this.sheetViewHeight = height;
|
|
@@ -51371,14 +51399,14 @@
|
|
|
51371
51399
|
this.recomputeViewports();
|
|
51372
51400
|
}
|
|
51373
51401
|
recomputeViewports() {
|
|
51374
|
-
for (
|
|
51402
|
+
for (const sheetId of this.getters.getSheetIds()) {
|
|
51375
51403
|
this.resetViewports(sheetId);
|
|
51376
51404
|
}
|
|
51377
51405
|
}
|
|
51378
51406
|
setSheetViewOffset(offsetX, offsetY) {
|
|
51379
51407
|
const sheetId = this.getters.getActiveSheetId();
|
|
51380
51408
|
const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
|
|
51381
|
-
|
|
51409
|
+
this.getSubViewports(sheetId).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
|
|
51382
51410
|
}
|
|
51383
51411
|
getViewportOffset(sheetId) {
|
|
51384
51412
|
return {
|
|
@@ -51393,8 +51421,10 @@
|
|
|
51393
51421
|
const { xSplit, ySplit } = this.getters.getPaneDivisions(sheetId);
|
|
51394
51422
|
const nCols = this.getters.getNumberCols(sheetId);
|
|
51395
51423
|
const nRows = this.getters.getNumberRows(sheetId);
|
|
51396
|
-
const colOffset = this.getters.getColRowOffset("COL", 0, xSplit, sheetId);
|
|
51397
|
-
const rowOffset = this.getters.getColRowOffset("ROW", 0, ySplit, sheetId);
|
|
51424
|
+
const colOffset = Math.min(this.getters.getColRowOffset("COL", 0, xSplit, sheetId), this.sheetViewWidth);
|
|
51425
|
+
const rowOffset = Math.min(this.getters.getColRowOffset("ROW", 0, ySplit, sheetId), this.sheetViewHeight);
|
|
51426
|
+
const unfrozenWidth = Math.max(this.sheetViewWidth - colOffset, 0);
|
|
51427
|
+
const unfrozenHeight = Math.max(this.sheetViewHeight - rowOffset, 0);
|
|
51398
51428
|
const { xRatio, yRatio } = this.getFrozenSheetViewRatio(sheetId);
|
|
51399
51429
|
const canScrollHorizontally = xRatio < 1.0;
|
|
51400
51430
|
const canScrollVertically = yRatio < 1.0;
|
|
@@ -51405,14 +51435,14 @@
|
|
|
51405
51435
|
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 })) ||
|
|
51406
51436
|
undefined,
|
|
51407
51437
|
topRight: (ySplit &&
|
|
51408
|
-
new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: 0, bottom: ySplit - 1 }, { width:
|
|
51438
|
+
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 })) ||
|
|
51409
51439
|
undefined,
|
|
51410
51440
|
bottomLeft: (xSplit &&
|
|
51411
|
-
new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: ySplit, bottom: nRows - 1 }, { width: colOffset, height:
|
|
51441
|
+
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 })) ||
|
|
51412
51442
|
undefined,
|
|
51413
51443
|
bottomRight: new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: ySplit, bottom: nRows - 1 }, {
|
|
51414
|
-
width:
|
|
51415
|
-
height:
|
|
51444
|
+
width: unfrozenWidth,
|
|
51445
|
+
height: unfrozenHeight,
|
|
51416
51446
|
}, { canScrollHorizontally, canScrollVertically }, {
|
|
51417
51447
|
x: canScrollHorizontally ? previousOffset.x : 0,
|
|
51418
51448
|
y: canScrollVertically ? previousOffset.y : 0,
|
|
@@ -51424,7 +51454,7 @@
|
|
|
51424
51454
|
* Adjust the viewport such that the anchor position is visible
|
|
51425
51455
|
*/
|
|
51426
51456
|
refreshViewport(sheetId, anchorPosition) {
|
|
51427
|
-
|
|
51457
|
+
this.getSubViewports(sheetId).forEach((viewport) => {
|
|
51428
51458
|
viewport.adjustViewportZone();
|
|
51429
51459
|
viewport.adjustPosition(anchorPosition);
|
|
51430
51460
|
});
|
|
@@ -51489,12 +51519,26 @@
|
|
|
51489
51519
|
const height = this.sheetViewHeight + this.gridOffsetY;
|
|
51490
51520
|
return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
|
|
51491
51521
|
}
|
|
51492
|
-
|
|
51493
|
-
|
|
51494
|
-
|
|
51495
|
-
|
|
51496
|
-
|
|
51497
|
-
|
|
51522
|
+
mapViewportsToRect(sheetId, rectCallBack) {
|
|
51523
|
+
let x = Infinity;
|
|
51524
|
+
let y = Infinity;
|
|
51525
|
+
let width = 0;
|
|
51526
|
+
let height = 0;
|
|
51527
|
+
let hasViewports = false;
|
|
51528
|
+
for (const viewport of this.getSubViewports(sheetId)) {
|
|
51529
|
+
const rect = rectCallBack(viewport);
|
|
51530
|
+
if (rect) {
|
|
51531
|
+
hasViewports = true;
|
|
51532
|
+
x = Math.min(x, rect.x);
|
|
51533
|
+
y = Math.min(y, rect.y);
|
|
51534
|
+
width = Math.max(width, rect.x + rect.width);
|
|
51535
|
+
height = Math.max(height, rect.y + rect.height);
|
|
51536
|
+
}
|
|
51537
|
+
}
|
|
51538
|
+
if (!hasViewports) {
|
|
51539
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
51540
|
+
}
|
|
51541
|
+
return { x, y, width: width - x, height: height - y };
|
|
51498
51542
|
}
|
|
51499
51543
|
}
|
|
51500
51544
|
|
|
@@ -57803,9 +57847,9 @@
|
|
|
57803
57847
|
exports.tokenize = tokenize;
|
|
57804
57848
|
|
|
57805
57849
|
|
|
57806
|
-
__info__.version = "17.0.
|
|
57807
|
-
__info__.date = "2025-
|
|
57808
|
-
__info__.hash = "
|
|
57850
|
+
__info__.version = "17.0.49";
|
|
57851
|
+
__info__.date = "2025-02-10T08:55:47.771Z";
|
|
57852
|
+
__info__.hash = "1049319";
|
|
57809
57853
|
|
|
57810
57854
|
|
|
57811
57855
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|