@odoo/o-spreadsheet 16.2.3 → 16.2.4
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 +176 -64
- package/dist/o-spreadsheet.d.ts +12 -5
- package/dist/o-spreadsheet.esm.js +176 -64
- package/dist/o-spreadsheet.iife.js +176 -64
- package/dist/o-spreadsheet.iife.min.js +238 -238
- package/package.json +1 -1
|
@@ -1008,6 +1008,10 @@ function deepEquals(o1, o2) {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
return true;
|
|
1010
1010
|
}
|
|
1011
|
+
/** Check if the given array contains all the values of the other array. */
|
|
1012
|
+
function includesAll(arr, values) {
|
|
1013
|
+
return values.every((value) => arr.includes(value));
|
|
1014
|
+
}
|
|
1011
1015
|
/**
|
|
1012
1016
|
* Return an object with all the keys in the object that have a falsy value removed.
|
|
1013
1017
|
*/
|
|
@@ -1681,12 +1685,77 @@ const numberRepresentation = [];
|
|
|
1681
1685
|
* - all digit stored in the decimal part of the number
|
|
1682
1686
|
*
|
|
1683
1687
|
* The 'maxDecimal' parameter allows to indicate the number of digits to not
|
|
1684
|
-
* exceed in the decimal part, in which case digits are rounded
|
|
1688
|
+
* exceed in the decimal part, in which case digits are rounded.
|
|
1685
1689
|
*
|
|
1686
|
-
* Intl.Numberformat is used to properly handle all the roundings.
|
|
1687
|
-
* e.g. 1234.7 with format ### (<> maxDecimals=0) should become 1235, not 1234
|
|
1688
1690
|
**/
|
|
1689
1691
|
function splitNumber(value, maxDecimals = MAX_DECIMAL_PLACES) {
|
|
1692
|
+
const asString = value.toString();
|
|
1693
|
+
if (asString.includes("e"))
|
|
1694
|
+
return splitNumberIntl(value, maxDecimals);
|
|
1695
|
+
if (Number.isInteger(value)) {
|
|
1696
|
+
return { integerDigits: asString, decimalDigits: undefined };
|
|
1697
|
+
}
|
|
1698
|
+
const indexOfDot = asString.indexOf(".");
|
|
1699
|
+
let integerDigits = asString.substring(0, indexOfDot);
|
|
1700
|
+
let decimalDigits = asString.substring(indexOfDot + 1);
|
|
1701
|
+
if (maxDecimals === 0) {
|
|
1702
|
+
if (Number(decimalDigits[0]) >= 5) {
|
|
1703
|
+
integerDigits = (Number(integerDigits) + 1).toString();
|
|
1704
|
+
}
|
|
1705
|
+
return { integerDigits, decimalDigits: undefined };
|
|
1706
|
+
}
|
|
1707
|
+
if (decimalDigits.length > maxDecimals) {
|
|
1708
|
+
const { integerDigits: roundedIntegerDigits, decimalDigits: roundedDecimalDigits } = limitDecimalDigits(decimalDigits, maxDecimals);
|
|
1709
|
+
decimalDigits = roundedDecimalDigits;
|
|
1710
|
+
if (roundedIntegerDigits !== "0") {
|
|
1711
|
+
integerDigits = (Number(integerDigits) + Number(roundedIntegerDigits)).toString();
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
return { integerDigits, decimalDigits: removeTrailingZeroes(decimalDigits || "") };
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Return the given string minus the trailing "0" characters.
|
|
1718
|
+
*
|
|
1719
|
+
* @param numberString : a string of integers
|
|
1720
|
+
* @returns the numberString, minus the eventual zeroes at the end
|
|
1721
|
+
*/
|
|
1722
|
+
function removeTrailingZeroes(numberString) {
|
|
1723
|
+
let i = numberString.length - 1;
|
|
1724
|
+
while (i >= 0 && numberString[i] === "0") {
|
|
1725
|
+
i--;
|
|
1726
|
+
}
|
|
1727
|
+
return numberString.slice(0, i + 1) || undefined;
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Limit the size of the decimal part of a number to the given number of digits.
|
|
1731
|
+
*/
|
|
1732
|
+
function limitDecimalDigits(decimalDigits, maxDecimals) {
|
|
1733
|
+
let integerDigits = "0";
|
|
1734
|
+
let resultDecimalDigits = decimalDigits;
|
|
1735
|
+
// Note : we'd want to simply use number.toFixed() to handle the max digits & rounding,
|
|
1736
|
+
// but it has very strange behaviour. Ex: 12.345.toFixed(2) => "12.35", but 1.345.toFixed(2) => "1.34"
|
|
1737
|
+
let slicedDecimalDigits = decimalDigits.slice(0, maxDecimals);
|
|
1738
|
+
const i = maxDecimals;
|
|
1739
|
+
if (Number(Number(decimalDigits[i]) < 5)) {
|
|
1740
|
+
return { integerDigits, decimalDigits: slicedDecimalDigits };
|
|
1741
|
+
}
|
|
1742
|
+
// round up
|
|
1743
|
+
const slicedRoundedUp = (Number(slicedDecimalDigits) + 1).toString();
|
|
1744
|
+
if (slicedRoundedUp.length > slicedDecimalDigits.length) {
|
|
1745
|
+
integerDigits = (Number(integerDigits) + 1).toString();
|
|
1746
|
+
resultDecimalDigits = undefined;
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
resultDecimalDigits = slicedRoundedUp;
|
|
1750
|
+
}
|
|
1751
|
+
return { integerDigits, decimalDigits: resultDecimalDigits };
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Split numbers into decimal/integer digits using Intl.NumberFormat.
|
|
1755
|
+
* Supports numbers with a lot of digits that are transformed to scientific notation by
|
|
1756
|
+
* number.toString(), but is slow.
|
|
1757
|
+
*/
|
|
1758
|
+
function splitNumberIntl(value, maxDecimals = MAX_DECIMAL_PLACES) {
|
|
1690
1759
|
let formatter = numberRepresentation[maxDecimals];
|
|
1691
1760
|
if (!formatter) {
|
|
1692
1761
|
formatter = new Intl.NumberFormat("en-US", {
|
|
@@ -9135,6 +9204,11 @@ colMenuRegistry
|
|
|
9135
9204
|
name: REMOVE_COLUMNS_NAME,
|
|
9136
9205
|
sequence: 90,
|
|
9137
9206
|
action: REMOVE_COLUMNS_ACTION,
|
|
9207
|
+
isVisible: (env) => {
|
|
9208
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
9209
|
+
const selectedCols = env.model.getters.getElementsFromSelection("COL");
|
|
9210
|
+
return env.model.getters.canRemoveHeaders(sheetId, "COL", selectedCols);
|
|
9211
|
+
},
|
|
9138
9212
|
})
|
|
9139
9213
|
.add("clear_column", {
|
|
9140
9214
|
name: DELETE_CONTENT_COLUMNS_NAME,
|
|
@@ -9147,9 +9221,8 @@ colMenuRegistry
|
|
|
9147
9221
|
action: HIDE_COLUMNS_ACTION,
|
|
9148
9222
|
isVisible: (env) => {
|
|
9149
9223
|
const sheetId = env.model.getters.getActiveSheetId();
|
|
9150
|
-
const
|
|
9151
|
-
return
|
|
9152
|
-
hiddenCols.length + env.model.getters.getElementsFromSelection("COL").length);
|
|
9224
|
+
const selectedCols = env.model.getters.getElementsFromSelection("COL");
|
|
9225
|
+
return env.model.getters.canRemoveHeaders(sheetId, "COL", selectedCols);
|
|
9153
9226
|
},
|
|
9154
9227
|
separator: true,
|
|
9155
9228
|
})
|
|
@@ -9223,6 +9296,11 @@ rowMenuRegistry
|
|
|
9223
9296
|
name: REMOVE_ROWS_NAME,
|
|
9224
9297
|
sequence: 70,
|
|
9225
9298
|
action: REMOVE_ROWS_ACTION,
|
|
9299
|
+
isVisible: (env) => {
|
|
9300
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
9301
|
+
const selectedRows = env.model.getters.getElementsFromSelection("ROW");
|
|
9302
|
+
return env.model.getters.canRemoveHeaders(sheetId, "ROW", selectedRows);
|
|
9303
|
+
},
|
|
9226
9304
|
})
|
|
9227
9305
|
.add("clear_row", {
|
|
9228
9306
|
name: DELETE_CONTENT_ROWS_NAME,
|
|
@@ -9235,9 +9313,8 @@ rowMenuRegistry
|
|
|
9235
9313
|
action: HIDE_ROWS_ACTION,
|
|
9236
9314
|
isVisible: (env) => {
|
|
9237
9315
|
const sheetId = env.model.getters.getActiveSheetId();
|
|
9238
|
-
const
|
|
9239
|
-
return
|
|
9240
|
-
hiddenRows.length + env.model.getters.getElementsFromSelection("ROW").length);
|
|
9316
|
+
const selectedRows = env.model.getters.getElementsFromSelection("ROW");
|
|
9317
|
+
return env.model.getters.canRemoveHeaders(sheetId, "ROW", selectedRows);
|
|
9241
9318
|
},
|
|
9242
9319
|
separator: true,
|
|
9243
9320
|
})
|
|
@@ -21973,8 +22050,8 @@ class Grid extends owl.Component {
|
|
|
21973
22050
|
},
|
|
21974
22051
|
"CTRL+END": () => {
|
|
21975
22052
|
const sheetId = this.env.model.getters.getActiveSheetId();
|
|
21976
|
-
const col = this.env.model.getters.findVisibleHeader(sheetId, "COL",
|
|
21977
|
-
const row = this.env.model.getters.findVisibleHeader(sheetId, "ROW",
|
|
22053
|
+
const col = this.env.model.getters.findVisibleHeader(sheetId, "COL", this.env.model.getters.getNumberCols(sheetId) - 1, 0);
|
|
22054
|
+
const row = this.env.model.getters.findVisibleHeader(sheetId, "ROW", this.env.model.getters.getNumberRows(sheetId) - 1, 0);
|
|
21978
22055
|
this.env.model.selection.selectCell(col, row);
|
|
21979
22056
|
},
|
|
21980
22057
|
"SHIFT+ ": () => {
|
|
@@ -22054,9 +22131,10 @@ class Grid extends owl.Component {
|
|
|
22054
22131
|
this.focus();
|
|
22055
22132
|
}
|
|
22056
22133
|
focus() {
|
|
22134
|
+
var _a;
|
|
22057
22135
|
if (!this.env.model.getters.getSelectedFigureId() &&
|
|
22058
22136
|
this.env.model.getters.getEditionMode() === "inactive") {
|
|
22059
|
-
this.hiddenInput.el.focus();
|
|
22137
|
+
(_a = this.hiddenInput.el) === null || _a === void 0 ? void 0 : _a.focus();
|
|
22060
22138
|
}
|
|
22061
22139
|
}
|
|
22062
22140
|
get gridEl() {
|
|
@@ -25951,7 +26029,7 @@ function load(data, verboseImport) {
|
|
|
25951
26029
|
}
|
|
25952
26030
|
}
|
|
25953
26031
|
}
|
|
25954
|
-
data =
|
|
26032
|
+
data = deepCopy(data);
|
|
25955
26033
|
// apply migrations, if needed
|
|
25956
26034
|
if ("version" in data) {
|
|
25957
26035
|
if (data.version < CURRENT_VERSION) {
|
|
@@ -29394,7 +29472,7 @@ class HeaderVisibilityPlugin extends CorePlugin {
|
|
|
29394
29472
|
allowDispatch(cmd) {
|
|
29395
29473
|
switch (cmd.type) {
|
|
29396
29474
|
case "HIDE_COLUMNS_ROWS": {
|
|
29397
|
-
if (!this.
|
|
29475
|
+
if (!this.getters.tryGetSheet(cmd.sheetId)) {
|
|
29398
29476
|
return 27 /* CommandResult.InvalidSheetId */;
|
|
29399
29477
|
}
|
|
29400
29478
|
const hiddenGroup = cmd.dimension === "COL"
|
|
@@ -29407,6 +29485,14 @@ class HeaderVisibilityPlugin extends CorePlugin {
|
|
|
29407
29485
|
? 0 /* CommandResult.Success */
|
|
29408
29486
|
: 66 /* CommandResult.TooManyHiddenElements */;
|
|
29409
29487
|
}
|
|
29488
|
+
case "REMOVE_COLUMNS_ROWS":
|
|
29489
|
+
if (!this.getters.tryGetSheet(cmd.sheetId)) {
|
|
29490
|
+
return 27 /* CommandResult.InvalidSheetId */;
|
|
29491
|
+
}
|
|
29492
|
+
if (!this.canRemoveHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
|
|
29493
|
+
return 8 /* CommandResult.NotEnoughElements */;
|
|
29494
|
+
}
|
|
29495
|
+
return 0 /* CommandResult.Success */;
|
|
29410
29496
|
}
|
|
29411
29497
|
return 0 /* CommandResult.Success */;
|
|
29412
29498
|
}
|
|
@@ -29453,6 +29539,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
|
|
|
29453
29539
|
}
|
|
29454
29540
|
return;
|
|
29455
29541
|
}
|
|
29542
|
+
canRemoveHeaders(sheetId, dimension, elements) {
|
|
29543
|
+
const visibleHeaders = this.getAllVisibleHeaders(sheetId, dimension);
|
|
29544
|
+
return !includesAll(elements, visibleHeaders);
|
|
29545
|
+
}
|
|
29456
29546
|
isRowHiddenByUser(sheetId, index) {
|
|
29457
29547
|
return this.hiddenHeaders[sheetId].ROW[index];
|
|
29458
29548
|
}
|
|
@@ -29497,6 +29587,9 @@ class HeaderVisibilityPlugin extends CorePlugin {
|
|
|
29497
29587
|
}
|
|
29498
29588
|
return consecutiveIndexes;
|
|
29499
29589
|
}
|
|
29590
|
+
getAllVisibleHeaders(sheetId, dimension) {
|
|
29591
|
+
return range(0, this.hiddenHeaders[sheetId][dimension].length).filter((i) => !this.hiddenHeaders[sheetId][dimension][i]);
|
|
29592
|
+
}
|
|
29500
29593
|
import(data) {
|
|
29501
29594
|
var _a, _b;
|
|
29502
29595
|
for (let sheet of data.sheets) {
|
|
@@ -29544,6 +29637,7 @@ class HeaderVisibilityPlugin extends CorePlugin {
|
|
|
29544
29637
|
}
|
|
29545
29638
|
}
|
|
29546
29639
|
HeaderVisibilityPlugin.getters = [
|
|
29640
|
+
"canRemoveHeaders",
|
|
29547
29641
|
"getHiddenColsGroups",
|
|
29548
29642
|
"getHiddenRowsGroups",
|
|
29549
29643
|
"isRowHiddenByUser",
|
|
@@ -30562,14 +30656,6 @@ class SheetPlugin extends CorePlugin {
|
|
|
30562
30656
|
return this.orderedSheetIds.length > 1
|
|
30563
30657
|
? 0 /* CommandResult.Success */
|
|
30564
30658
|
: 9 /* CommandResult.NotEnoughSheets */;
|
|
30565
|
-
case "REMOVE_COLUMNS_ROWS": {
|
|
30566
|
-
const length = cmd.dimension === "COL"
|
|
30567
|
-
? this.getNumberCols(cmd.sheetId)
|
|
30568
|
-
: this.getNumberRows(cmd.sheetId);
|
|
30569
|
-
return length > cmd.elements.length
|
|
30570
|
-
? 0 /* CommandResult.Success */
|
|
30571
|
-
: 8 /* CommandResult.NotEnoughElements */;
|
|
30572
|
-
}
|
|
30573
30659
|
case "FREEZE_ROWS": {
|
|
30574
30660
|
return this.checkValidations(cmd, this.checkRowFreezeQuantity, this.checkRowFreezeOverlapMerge);
|
|
30575
30661
|
}
|
|
@@ -31036,7 +31122,7 @@ class SheetPlugin extends CorePlugin {
|
|
|
31036
31122
|
duplicateSheet(fromId, toId) {
|
|
31037
31123
|
const sheet = this.getSheet(fromId);
|
|
31038
31124
|
const toName = this.getDuplicateSheetName(sheet.name);
|
|
31039
|
-
const newSheet =
|
|
31125
|
+
const newSheet = deepCopy(sheet);
|
|
31040
31126
|
newSheet.id = toId;
|
|
31041
31127
|
newSheet.name = toName;
|
|
31042
31128
|
for (let col = 0; col <= newSheet.numberOfCols; col++) {
|
|
@@ -31163,10 +31249,10 @@ class SheetPlugin extends CorePlugin {
|
|
|
31163
31249
|
}
|
|
31164
31250
|
}
|
|
31165
31251
|
moveCellOnColumnsDeletion(sheet, deletedColumn) {
|
|
31166
|
-
for (let
|
|
31167
|
-
const
|
|
31252
|
+
for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
|
|
31253
|
+
const row = sheet.rows[rowIndex];
|
|
31168
31254
|
for (let i in row.cells) {
|
|
31169
|
-
const colIndex =
|
|
31255
|
+
const colIndex = Number(i);
|
|
31170
31256
|
const cellId = row.cells[i];
|
|
31171
31257
|
if (cellId) {
|
|
31172
31258
|
if (colIndex === deletedColumn) {
|
|
@@ -31193,11 +31279,11 @@ class SheetPlugin extends CorePlugin {
|
|
|
31193
31279
|
*/
|
|
31194
31280
|
moveCellsOnAddition(sheet, addedElement, quantity, dimension) {
|
|
31195
31281
|
const commands = [];
|
|
31196
|
-
for (
|
|
31197
|
-
const
|
|
31282
|
+
for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
|
|
31283
|
+
const row = sheet.rows[rowIndex];
|
|
31198
31284
|
if (dimension !== "rows" || rowIndex >= addedElement) {
|
|
31199
31285
|
for (let i in row.cells) {
|
|
31200
|
-
const colIndex =
|
|
31286
|
+
const colIndex = Number(i);
|
|
31201
31287
|
const cellId = row.cells[i];
|
|
31202
31288
|
if (cellId) {
|
|
31203
31289
|
if (dimension === "rows" || colIndex >= addedElement) {
|
|
@@ -31227,11 +31313,11 @@ class SheetPlugin extends CorePlugin {
|
|
|
31227
31313
|
*/
|
|
31228
31314
|
moveCellOnRowsDeletion(sheet, deleteFromRow, deleteToRow) {
|
|
31229
31315
|
const numberRows = deleteToRow - deleteFromRow + 1;
|
|
31230
|
-
for (let
|
|
31231
|
-
const
|
|
31316
|
+
for (let rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
|
|
31317
|
+
const row = sheet.rows[rowIndex];
|
|
31232
31318
|
if (rowIndex >= deleteFromRow && rowIndex <= deleteToRow) {
|
|
31233
31319
|
for (let i in row.cells) {
|
|
31234
|
-
const colIndex =
|
|
31320
|
+
const colIndex = Number(i);
|
|
31235
31321
|
const cellId = row.cells[i];
|
|
31236
31322
|
if (cellId) {
|
|
31237
31323
|
this.dispatch("CLEAR_CELL", {
|
|
@@ -31244,7 +31330,7 @@ class SheetPlugin extends CorePlugin {
|
|
|
31244
31330
|
}
|
|
31245
31331
|
if (rowIndex > deleteToRow) {
|
|
31246
31332
|
for (let i in row.cells) {
|
|
31247
|
-
const colIndex =
|
|
31333
|
+
const colIndex = Number(i);
|
|
31248
31334
|
const cellId = row.cells[i];
|
|
31249
31335
|
if (cellId) {
|
|
31250
31336
|
this.dispatch("UPDATE_CELL_POSITION", {
|
|
@@ -31262,7 +31348,7 @@ class SheetPlugin extends CorePlugin {
|
|
|
31262
31348
|
const rows = [];
|
|
31263
31349
|
const cellsQueue = sheet.rows.map((row) => row.cells);
|
|
31264
31350
|
for (let i in sheet.rows) {
|
|
31265
|
-
if (
|
|
31351
|
+
if (Number(i) === index) {
|
|
31266
31352
|
continue;
|
|
31267
31353
|
}
|
|
31268
31354
|
rows.push({
|
|
@@ -32433,13 +32519,11 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
32433
32519
|
return Boolean(id && ((_b = (_a = this.filterValues[sheetId]) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b.length));
|
|
32434
32520
|
}
|
|
32435
32521
|
intersectZoneWithViewport(sheetId, zone) {
|
|
32436
|
-
const colsRange = range(zone.left, zone.right + 1);
|
|
32437
|
-
const rowsRange = range(zone.top, zone.bottom + 1);
|
|
32438
32522
|
return {
|
|
32439
|
-
left: this.getters.findVisibleHeader(sheetId, "COL",
|
|
32440
|
-
right: this.getters.findVisibleHeader(sheetId, "COL",
|
|
32441
|
-
top: this.getters.findVisibleHeader(sheetId, "ROW",
|
|
32442
|
-
bottom: this.getters.findVisibleHeader(sheetId, "ROW",
|
|
32523
|
+
left: this.getters.findVisibleHeader(sheetId, "COL", zone.left, zone.right),
|
|
32524
|
+
right: this.getters.findVisibleHeader(sheetId, "COL", zone.right, zone.left),
|
|
32525
|
+
top: this.getters.findVisibleHeader(sheetId, "ROW", zone.top, zone.bottom),
|
|
32526
|
+
bottom: this.getters.findVisibleHeader(sheetId, "ROW", zone.bottom, zone.top),
|
|
32443
32527
|
};
|
|
32444
32528
|
}
|
|
32445
32529
|
updateFilter({ col, row, values, sheetId }) {
|
|
@@ -34546,13 +34630,33 @@ class HeaderVisibilityUIPlugin extends UIPlugin {
|
|
|
34546
34630
|
getNextVisibleCellPosition({ sheetId, col, row }) {
|
|
34547
34631
|
return {
|
|
34548
34632
|
sheetId,
|
|
34549
|
-
col: this.findVisibleHeader(sheetId, "COL",
|
|
34550
|
-
row: this.findVisibleHeader(sheetId, "ROW",
|
|
34633
|
+
col: this.findVisibleHeader(sheetId, "COL", col, this.getters.getNumberCols(sheetId) - 1),
|
|
34634
|
+
row: this.findVisibleHeader(sheetId, "ROW", row, this.getters.getNumberRows(sheetId) - 1),
|
|
34551
34635
|
};
|
|
34552
34636
|
}
|
|
34553
|
-
|
|
34554
|
-
|
|
34555
|
-
|
|
34637
|
+
/**
|
|
34638
|
+
* Find the first visible header in the range [`from` => `to`].
|
|
34639
|
+
*
|
|
34640
|
+
* Both `from` and `to` are inclusive.
|
|
34641
|
+
*/
|
|
34642
|
+
findVisibleHeader(sheetId, dimension, from, to) {
|
|
34643
|
+
if (from <= to) {
|
|
34644
|
+
for (let i = from; i <= to; i++) {
|
|
34645
|
+
if (this.getters.doesHeaderExist(sheetId, dimension, i) &&
|
|
34646
|
+
!this.isHeaderHidden(sheetId, dimension, i)) {
|
|
34647
|
+
return i;
|
|
34648
|
+
}
|
|
34649
|
+
}
|
|
34650
|
+
}
|
|
34651
|
+
if (from > to) {
|
|
34652
|
+
for (let i = from; i >= to; i--) {
|
|
34653
|
+
if (this.getters.doesHeaderExist(sheetId, dimension, i) &&
|
|
34654
|
+
!this.isHeaderHidden(sheetId, dimension, i)) {
|
|
34655
|
+
return i;
|
|
34656
|
+
}
|
|
34657
|
+
}
|
|
34658
|
+
}
|
|
34659
|
+
return undefined;
|
|
34556
34660
|
}
|
|
34557
34661
|
findLastVisibleColRowIndex(sheetId, dimension, { last, first }) {
|
|
34558
34662
|
const lastVisibleIndex = range(last, first, -1).find((index) => !this.isHeaderHidden(sheetId, dimension, index));
|
|
@@ -34560,7 +34664,7 @@ class HeaderVisibilityUIPlugin extends UIPlugin {
|
|
|
34560
34664
|
}
|
|
34561
34665
|
findFirstVisibleColRowIndex(sheetId, dimension) {
|
|
34562
34666
|
const numberOfHeaders = this.getters.getNumberHeaders(sheetId, dimension);
|
|
34563
|
-
for (let i = 0; i < numberOfHeaders
|
|
34667
|
+
for (let i = 0; i < numberOfHeaders; i++) {
|
|
34564
34668
|
if (dimension === "COL" && !this.isColHidden(sheetId, i)) {
|
|
34565
34669
|
return i;
|
|
34566
34670
|
}
|
|
@@ -42764,8 +42868,8 @@ class SelectionStreamProcessorImpl {
|
|
|
42764
42868
|
}
|
|
42765
42869
|
const { left, right, top, bottom } = zone;
|
|
42766
42870
|
const sheetId = this.getters.getActiveSheetId();
|
|
42767
|
-
const refCol = this.getters.findVisibleHeader(sheetId, "COL",
|
|
42768
|
-
const refRow = this.getters.findVisibleHeader(sheetId, "ROW",
|
|
42871
|
+
const refCol = this.getters.findVisibleHeader(sheetId, "COL", left, right);
|
|
42872
|
+
const refRow = this.getters.findVisibleHeader(sheetId, "ROW", top, bottom);
|
|
42769
42873
|
if (refRow === undefined || refCol === undefined) {
|
|
42770
42874
|
return 17 /* CommandResult.SelectionOutOfBound */;
|
|
42771
42875
|
}
|
|
@@ -42840,10 +42944,10 @@ class SelectionStreamProcessorImpl {
|
|
|
42840
42944
|
const { col: anchorCol, row: anchorRow } = anchor.cell;
|
|
42841
42945
|
return {
|
|
42842
42946
|
col: this.getters.isColHidden(sheetId, anchorCol)
|
|
42843
|
-
? this.getters.findVisibleHeader(sheetId, "COL",
|
|
42947
|
+
? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
|
|
42844
42948
|
: anchorCol,
|
|
42845
42949
|
row: this.getters.isRowHidden(sheetId, anchorRow)
|
|
42846
|
-
? this.getters.findVisibleHeader(sheetId, "ROW",
|
|
42950
|
+
? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
|
|
42847
42951
|
: anchorRow,
|
|
42848
42952
|
};
|
|
42849
42953
|
}
|
|
@@ -44593,6 +44697,8 @@ class Model extends EventBus {
|
|
|
44593
44697
|
* Internal status of the model. Important for command handling coordination
|
|
44594
44698
|
*/
|
|
44595
44699
|
this.status = 0 /* Status.Ready */;
|
|
44700
|
+
this.handlers = [];
|
|
44701
|
+
this.coreHandlers = [];
|
|
44596
44702
|
/**
|
|
44597
44703
|
* The dispatch method is the only entry point to manipulate data in the model.
|
|
44598
44704
|
* This is through this method that commands are dispatched most of the time
|
|
@@ -44697,6 +44803,8 @@ class Model extends EventBus {
|
|
|
44697
44803
|
this.uuidGenerator.setIsFastStrategy(true);
|
|
44698
44804
|
// Initiate stream processor
|
|
44699
44805
|
this.selection = new SelectionStreamProcessorImpl(this.getters);
|
|
44806
|
+
this.coreHandlers.push(this.range);
|
|
44807
|
+
this.handlers.push(this.range);
|
|
44700
44808
|
this.corePluginConfig = this.setupCorePluginConfig();
|
|
44701
44809
|
this.uiPluginConfig = this.setupUiPluginConfig();
|
|
44702
44810
|
// registering plugins
|
|
@@ -44705,15 +44813,23 @@ class Model extends EventBus {
|
|
|
44705
44813
|
}
|
|
44706
44814
|
Object.assign(this.getters, this.coreGetters);
|
|
44707
44815
|
for (let Plugin of statefulUIPluginRegistry.getAll()) {
|
|
44708
|
-
this.
|
|
44816
|
+
const plugin = this.setupUiPlugin(Plugin);
|
|
44817
|
+
this.statefulUIPlugins.push(plugin);
|
|
44818
|
+
this.handlers.push(plugin);
|
|
44709
44819
|
}
|
|
44710
44820
|
for (let Plugin of coreViewsPluginRegistry.getAll()) {
|
|
44711
|
-
this.
|
|
44821
|
+
const plugin = this.setupUiPlugin(Plugin);
|
|
44822
|
+
this.coreViewsPlugins.push(plugin);
|
|
44823
|
+
this.handlers.push(plugin);
|
|
44824
|
+
this.coreHandlers.push(plugin);
|
|
44712
44825
|
}
|
|
44713
44826
|
for (let Plugin of featurePluginRegistry.getAll()) {
|
|
44714
|
-
this.
|
|
44827
|
+
const plugin = this.setupUiPlugin(Plugin);
|
|
44828
|
+
this.featurePlugins.push(plugin);
|
|
44829
|
+
this.handlers.push(plugin);
|
|
44715
44830
|
}
|
|
44716
44831
|
this.uuidGenerator.setIsFastStrategy(false);
|
|
44832
|
+
this.handlers.push(this.history);
|
|
44717
44833
|
// starting plugins
|
|
44718
44834
|
this.dispatch("START");
|
|
44719
44835
|
// Model should be the last permanent subscriber in the list since he should render
|
|
@@ -44735,12 +44851,6 @@ class Model extends EventBus {
|
|
|
44735
44851
|
// by owl, since we do not rely on reactivity
|
|
44736
44852
|
owl.markRaw(this);
|
|
44737
44853
|
}
|
|
44738
|
-
get handlers() {
|
|
44739
|
-
return [this.range, ...this.corePlugins, ...this.allUIPlugins, this.history];
|
|
44740
|
-
}
|
|
44741
|
-
get allUIPlugins() {
|
|
44742
|
-
return [...this.statefulUIPlugins, ...this.coreViewsPlugins, ...this.featurePlugins];
|
|
44743
|
-
}
|
|
44744
44854
|
joinSession() {
|
|
44745
44855
|
this.session.join(this.config.client);
|
|
44746
44856
|
}
|
|
@@ -44782,6 +44892,8 @@ class Model extends EventBus {
|
|
|
44782
44892
|
}
|
|
44783
44893
|
plugin.import(data);
|
|
44784
44894
|
this.corePlugins.push(plugin);
|
|
44895
|
+
this.coreHandlers.push(plugin);
|
|
44896
|
+
this.handlers.push(plugin);
|
|
44785
44897
|
}
|
|
44786
44898
|
onRemoteRevisionReceived({ commands }) {
|
|
44787
44899
|
for (let command of commands) {
|
|
@@ -44924,7 +45036,7 @@ class Model extends EventBus {
|
|
|
44924
45036
|
}
|
|
44925
45037
|
}
|
|
44926
45038
|
data.revisionId = this.session.getRevisionId() || DEFAULT_REVISION_ID;
|
|
44927
|
-
data =
|
|
45039
|
+
data = deepCopy(data);
|
|
44928
45040
|
return data;
|
|
44929
45041
|
}
|
|
44930
45042
|
updateMode(mode) {
|
|
@@ -44952,7 +45064,7 @@ class Model extends EventBus {
|
|
|
44952
45064
|
handler.exportForExcel(data);
|
|
44953
45065
|
}
|
|
44954
45066
|
}
|
|
44955
|
-
data =
|
|
45067
|
+
data = deepCopy(data);
|
|
44956
45068
|
return getXLSX(data);
|
|
44957
45069
|
}
|
|
44958
45070
|
garbageCollectExternalResources() {
|
|
@@ -45092,6 +45204,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
45092
45204
|
exports.tokenize = tokenize;
|
|
45093
45205
|
|
|
45094
45206
|
|
|
45095
|
-
__info__.version = '16.2.
|
|
45096
|
-
__info__.date = '2023-04-
|
|
45097
|
-
__info__.hash = '
|
|
45207
|
+
__info__.version = '16.2.4';
|
|
45208
|
+
__info__.date = '2023-04-21T07:30:02.765Z';
|
|
45209
|
+
__info__.hash = '7169d69';
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -984,9 +984,9 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
|
|
|
984
984
|
*/
|
|
985
985
|
private coreGetters;
|
|
986
986
|
uuidGenerator: UuidGenerator;
|
|
987
|
+
private readonly handlers;
|
|
988
|
+
private readonly coreHandlers;
|
|
987
989
|
constructor(data?: any, config?: Partial<ModelConfig>, stateUpdateMessages?: StateUpdateMessage[], uuidGenerator?: UuidGenerator, verboseImport?: boolean);
|
|
988
|
-
get handlers(): CommandHandler<Command>[];
|
|
989
|
-
get allUIPlugins(): UIPlugin[];
|
|
990
990
|
joinSession(): void;
|
|
991
991
|
leaveSession(): void;
|
|
992
992
|
private setupUiPlugin;
|
|
@@ -3384,14 +3384,16 @@ declare class HeaderSizePlugin extends CorePlugin<HeaderSizeState> implements He
|
|
|
3384
3384
|
}
|
|
3385
3385
|
|
|
3386
3386
|
declare class HeaderVisibilityPlugin extends CorePlugin {
|
|
3387
|
-
static getters: readonly ["getHiddenColsGroups", "getHiddenRowsGroups", "isRowHiddenByUser", "isColHiddenByUser"];
|
|
3387
|
+
static getters: readonly ["canRemoveHeaders", "getHiddenColsGroups", "getHiddenRowsGroups", "isRowHiddenByUser", "isColHiddenByUser"];
|
|
3388
3388
|
private readonly hiddenHeaders;
|
|
3389
|
-
allowDispatch(cmd: Command): CommandResult.Success | CommandResult.InvalidSheetId | CommandResult.TooManyHiddenElements;
|
|
3389
|
+
allowDispatch(cmd: Command): CommandResult.Success | CommandResult.NotEnoughElements | CommandResult.InvalidSheetId | CommandResult.TooManyHiddenElements;
|
|
3390
3390
|
handle(cmd: Command): void;
|
|
3391
|
+
canRemoveHeaders(sheetId: UID, dimension: Dimension, elements: HeaderIndex[]): boolean;
|
|
3391
3392
|
isRowHiddenByUser(sheetId: UID, index: HeaderIndex): boolean;
|
|
3392
3393
|
isColHiddenByUser(sheetId: UID, index: HeaderIndex): boolean;
|
|
3393
3394
|
getHiddenColsGroups(sheetId: UID): ConsecutiveIndexes[];
|
|
3394
3395
|
getHiddenRowsGroups(sheetId: UID): ConsecutiveIndexes[];
|
|
3396
|
+
private getAllVisibleHeaders;
|
|
3395
3397
|
import(data: WorkbookData): void;
|
|
3396
3398
|
exportForExcel(data: ExcelWorkbookData): void;
|
|
3397
3399
|
export(data: WorkbookData): void;
|
|
@@ -4199,7 +4201,12 @@ declare class HeaderVisibilityUIPlugin extends UIPlugin {
|
|
|
4199
4201
|
isColHidden(sheetId: UID, index: number): boolean;
|
|
4200
4202
|
isHeaderHidden(sheetId: UID, dimension: Dimension, index: number): boolean;
|
|
4201
4203
|
getNextVisibleCellPosition({ sheetId, col, row }: CellPosition): CellPosition;
|
|
4202
|
-
|
|
4204
|
+
/**
|
|
4205
|
+
* Find the first visible header in the range [`from` => `to`].
|
|
4206
|
+
*
|
|
4207
|
+
* Both `from` and `to` are inclusive.
|
|
4208
|
+
*/
|
|
4209
|
+
findVisibleHeader(sheetId: UID, dimension: Dimension, from: number, to: number): number | undefined;
|
|
4203
4210
|
findLastVisibleColRowIndex(sheetId: UID, dimension: Dimension, { last, first }: {
|
|
4204
4211
|
first: HeaderIndex;
|
|
4205
4212
|
last: HeaderIndex;
|