@odoo/o-spreadsheet 16.4.26 → 16.4.28
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 +92 -42
- package/dist/o-spreadsheet.d.ts +2 -1
- package/dist/o-spreadsheet.esm.js +92 -42
- package/dist/o-spreadsheet.iife.js +92 -42
- package/dist/o-spreadsheet.iife.min.js +254 -254
- package/dist/o_spreadsheet.xml +5 -5
- package/package.json +2 -2
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
}
|
|
524
524
|
// Generate new Id if the item didn't exist in the dictionary
|
|
525
525
|
const ids = Object.keys(itemsDic);
|
|
526
|
-
const maxId = ids.length === 0 ? 0 :
|
|
526
|
+
const maxId = ids.length === 0 ? 0 : largeMax(ids.map((id) => parseInt(id, 10)));
|
|
527
527
|
itemsDic[maxId + 1] = item;
|
|
528
528
|
return maxId + 1;
|
|
529
529
|
}
|
|
@@ -739,6 +739,34 @@
|
|
|
739
739
|
const newArray = [...array];
|
|
740
740
|
newArray.splice(index, 0, ...items);
|
|
741
741
|
return newArray;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Alternative to Math.max that works with large arrays.
|
|
745
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
746
|
+
*/
|
|
747
|
+
function largeMax(array) {
|
|
748
|
+
let len = array.length;
|
|
749
|
+
if (len < 100000)
|
|
750
|
+
return Math.max(...array);
|
|
751
|
+
let max = -Infinity;
|
|
752
|
+
while (len--) {
|
|
753
|
+
max = array[len] > max ? array[len] : max;
|
|
754
|
+
}
|
|
755
|
+
return max;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Alternative to Math.min that works with large arrays.
|
|
759
|
+
* Typically useful for arrays bigger than 100k elements.
|
|
760
|
+
*/
|
|
761
|
+
function largeMin(array) {
|
|
762
|
+
let len = array.length;
|
|
763
|
+
if (len < 100000)
|
|
764
|
+
return Math.min(...array);
|
|
765
|
+
let min = +Infinity;
|
|
766
|
+
while (len--) {
|
|
767
|
+
min = array[len] < min ? array[len] : min;
|
|
768
|
+
}
|
|
769
|
+
return min;
|
|
742
770
|
}
|
|
743
771
|
|
|
744
772
|
const RBA_REGEX = /rgba?\(|\s+|\)/gi;
|
|
@@ -16335,10 +16363,10 @@
|
|
|
16335
16363
|
}
|
|
16336
16364
|
}
|
|
16337
16365
|
return {
|
|
16338
|
-
labels:
|
|
16366
|
+
labels: Array.from(labelSet),
|
|
16339
16367
|
dataSetsValues: datasets.map((dataset, indexOfDataset) => ({
|
|
16340
16368
|
...dataset,
|
|
16341
|
-
data:
|
|
16369
|
+
data: Array.from(labelSet).map((label) => labelMap[label][indexOfDataset]),
|
|
16342
16370
|
})),
|
|
16343
16371
|
};
|
|
16344
16372
|
}
|
|
@@ -17059,7 +17087,7 @@
|
|
|
17059
17087
|
return undefined;
|
|
17060
17088
|
}
|
|
17061
17089
|
const labelsTimestamps = labelDates.map((date) => date.getTime());
|
|
17062
|
-
const period =
|
|
17090
|
+
const period = largeMax(labelsTimestamps) - largeMin(labelsTimestamps);
|
|
17063
17091
|
const minUnit = getFormatMinDisplayUnit(format);
|
|
17064
17092
|
if (UNIT_LENGTH.second >= UNIT_LENGTH[minUnit] && Milliseconds.inSeconds(period) < 180) {
|
|
17065
17093
|
return "second";
|
|
@@ -17501,7 +17529,7 @@
|
|
|
17501
17529
|
}
|
|
17502
17530
|
function getPieColors(colors, dataSetsValues) {
|
|
17503
17531
|
const pieColors = [];
|
|
17504
|
-
const maxLength =
|
|
17532
|
+
const maxLength = largeMax(dataSetsValues.map((ds) => ds.data.length));
|
|
17505
17533
|
for (let i = 0; i <= maxLength; i++) {
|
|
17506
17534
|
pieColors.push(colors.next());
|
|
17507
17535
|
}
|
|
@@ -18318,8 +18346,8 @@
|
|
|
18318
18346
|
let last;
|
|
18319
18347
|
const activesRows = env.model.getters.getActiveRows();
|
|
18320
18348
|
if (activesRows.size !== 0) {
|
|
18321
|
-
first =
|
|
18322
|
-
last =
|
|
18349
|
+
first = largeMin([...activesRows]);
|
|
18350
|
+
last = largeMax([...activesRows]);
|
|
18323
18351
|
}
|
|
18324
18352
|
else {
|
|
18325
18353
|
const zone = env.model.getters.getSelectedZones()[0];
|
|
@@ -18347,8 +18375,8 @@
|
|
|
18347
18375
|
let last;
|
|
18348
18376
|
const activeCols = env.model.getters.getActiveCols();
|
|
18349
18377
|
if (activeCols.size !== 0) {
|
|
18350
|
-
first =
|
|
18351
|
-
last =
|
|
18378
|
+
first = largeMin([...activeCols]);
|
|
18379
|
+
last = largeMax([...activeCols]);
|
|
18352
18380
|
}
|
|
18353
18381
|
else {
|
|
18354
18382
|
const zone = env.model.getters.getSelectedZones()[0];
|
|
@@ -18376,8 +18404,8 @@
|
|
|
18376
18404
|
let last;
|
|
18377
18405
|
const activesRows = env.model.getters.getActiveRows();
|
|
18378
18406
|
if (activesRows.size !== 0) {
|
|
18379
|
-
first =
|
|
18380
|
-
last =
|
|
18407
|
+
first = largeMin([...activesRows]);
|
|
18408
|
+
last = largeMax([...activesRows]);
|
|
18381
18409
|
}
|
|
18382
18410
|
else {
|
|
18383
18411
|
const zone = env.model.getters.getSelectedZones()[0];
|
|
@@ -18418,8 +18446,8 @@
|
|
|
18418
18446
|
let last;
|
|
18419
18447
|
const activeCols = env.model.getters.getActiveCols();
|
|
18420
18448
|
if (activeCols.size !== 0) {
|
|
18421
|
-
first =
|
|
18422
|
-
last =
|
|
18449
|
+
first = largeMin([...activeCols]);
|
|
18450
|
+
last = largeMax([...activeCols]);
|
|
18423
18451
|
}
|
|
18424
18452
|
else {
|
|
18425
18453
|
const zone = env.model.getters.getSelectedZones()[0];
|
|
@@ -18460,7 +18488,7 @@
|
|
|
18460
18488
|
let row;
|
|
18461
18489
|
let quantity;
|
|
18462
18490
|
if (activeRows.size) {
|
|
18463
|
-
row =
|
|
18491
|
+
row = largeMin([...activeRows]);
|
|
18464
18492
|
quantity = activeRows.size;
|
|
18465
18493
|
}
|
|
18466
18494
|
else {
|
|
@@ -18481,7 +18509,7 @@
|
|
|
18481
18509
|
let row;
|
|
18482
18510
|
let quantity;
|
|
18483
18511
|
if (activeRows.size) {
|
|
18484
|
-
row =
|
|
18512
|
+
row = largeMax([...activeRows]);
|
|
18485
18513
|
quantity = activeRows.size;
|
|
18486
18514
|
}
|
|
18487
18515
|
else {
|
|
@@ -18502,7 +18530,7 @@
|
|
|
18502
18530
|
let column;
|
|
18503
18531
|
let quantity;
|
|
18504
18532
|
if (activeCols.size) {
|
|
18505
|
-
column =
|
|
18533
|
+
column = largeMin([...activeCols]);
|
|
18506
18534
|
quantity = activeCols.size;
|
|
18507
18535
|
}
|
|
18508
18536
|
else {
|
|
@@ -18523,7 +18551,7 @@
|
|
|
18523
18551
|
let column;
|
|
18524
18552
|
let quantity;
|
|
18525
18553
|
if (activeCols.size) {
|
|
18526
|
-
column =
|
|
18554
|
+
column = largeMax([...activeCols]);
|
|
18527
18555
|
quantity = activeCols.size;
|
|
18528
18556
|
}
|
|
18529
18557
|
else {
|
|
@@ -19039,14 +19067,19 @@
|
|
|
19039
19067
|
children: [allFunctionListMenuBuilder],
|
|
19040
19068
|
};
|
|
19041
19069
|
function allFunctionListMenuBuilder() {
|
|
19042
|
-
const fnNames = functionRegistry.getKeys();
|
|
19070
|
+
const fnNames = functionRegistry.getKeys().filter((key) => !functionRegistry.get(key).hidden);
|
|
19043
19071
|
return createFormulaFunctions(fnNames);
|
|
19044
19072
|
}
|
|
19045
19073
|
const categoriesFunctionListMenuBuilder = () => {
|
|
19046
19074
|
const functions = functionRegistry.content;
|
|
19047
|
-
const categories = [
|
|
19075
|
+
const categories = [
|
|
19076
|
+
...new Set(functionRegistry
|
|
19077
|
+
.getAll()
|
|
19078
|
+
.filter((fn) => !fn.hidden)
|
|
19079
|
+
.map((fn) => fn.category)),
|
|
19080
|
+
].filter(isDefined$1);
|
|
19048
19081
|
return categories.sort().map((category, i) => {
|
|
19049
|
-
const functionsInCategory = Object.keys(functions).filter((key) => functions[key].category === category);
|
|
19082
|
+
const functionsInCategory = Object.keys(functions).filter((key) => functions[key].category === category && !functions[key].hidden);
|
|
19050
19083
|
return {
|
|
19051
19084
|
name: category,
|
|
19052
19085
|
children: createFormulaFunctions(functionsInCategory),
|
|
@@ -23387,6 +23420,9 @@
|
|
|
23387
23420
|
el?.focus({ preventScroll: true });
|
|
23388
23421
|
}
|
|
23389
23422
|
}, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
|
|
23423
|
+
owl.onWillUnmount(() => {
|
|
23424
|
+
this.props.onFigureDeleted();
|
|
23425
|
+
});
|
|
23390
23426
|
}
|
|
23391
23427
|
clickAnchor(dirX, dirY, ev) {
|
|
23392
23428
|
this.props.onClickAnchor(dirX, dirY, ev);
|
|
@@ -23405,6 +23441,7 @@
|
|
|
23405
23441
|
this.props.onFigureDeleted();
|
|
23406
23442
|
ev.stopPropagation();
|
|
23407
23443
|
ev.preventDefault();
|
|
23444
|
+
ev.stopPropagation();
|
|
23408
23445
|
break;
|
|
23409
23446
|
case "ArrowDown":
|
|
23410
23447
|
case "ArrowLeft":
|
|
@@ -23425,6 +23462,7 @@
|
|
|
23425
23462
|
});
|
|
23426
23463
|
ev.stopPropagation();
|
|
23427
23464
|
ev.preventDefault();
|
|
23465
|
+
ev.stopPropagation();
|
|
23428
23466
|
break;
|
|
23429
23467
|
}
|
|
23430
23468
|
}
|
|
@@ -24027,6 +24065,9 @@
|
|
|
24027
24065
|
this.assistantState.allowCellSelectionBehind = false;
|
|
24028
24066
|
}, 2000);
|
|
24029
24067
|
}
|
|
24068
|
+
get formulaArgSeparator() {
|
|
24069
|
+
return this.env.model.getters.getLocale().formulaArgSeparator + " ";
|
|
24070
|
+
}
|
|
24030
24071
|
}
|
|
24031
24072
|
FunctionDescriptionProvider.props = {
|
|
24032
24073
|
functionName: String,
|
|
@@ -24161,6 +24202,12 @@
|
|
|
24161
24202
|
owl.useEffect(() => {
|
|
24162
24203
|
this.processContent();
|
|
24163
24204
|
});
|
|
24205
|
+
owl.onPatched(() => {
|
|
24206
|
+
// Required because typing '=SUM' and double-clicking another cell leaves ShowProvider/ShowDescription true
|
|
24207
|
+
if (this.env.model.getters.getEditionMode() === "inactive") {
|
|
24208
|
+
this.processTokenAtCursor();
|
|
24209
|
+
}
|
|
24210
|
+
});
|
|
24164
24211
|
}
|
|
24165
24212
|
// ---------------------------------------------------------------------------
|
|
24166
24213
|
// Handlers
|
|
@@ -29018,7 +29065,7 @@
|
|
|
29018
29065
|
function getSheetDims(sheet) {
|
|
29019
29066
|
const dims = [0, 0];
|
|
29020
29067
|
for (let row of sheet.rows) {
|
|
29021
|
-
dims[0] = Math.max(dims[0],
|
|
29068
|
+
dims[0] = Math.max(dims[0], largeMax(row.cells.map((cell) => toCartesian(cell.xc).col)));
|
|
29022
29069
|
dims[1] = Math.max(dims[1], row.index);
|
|
29023
29070
|
}
|
|
29024
29071
|
dims[0] = Math.max(dims[0], EXCEL_IMPORT_DEFAULT_NUMBER_OF_COLS);
|
|
@@ -33515,7 +33562,7 @@
|
|
|
33515
33562
|
if (hiddenElements.size >= elements) {
|
|
33516
33563
|
return 69 /* CommandResult.TooManyHiddenElements */;
|
|
33517
33564
|
}
|
|
33518
|
-
else if (
|
|
33565
|
+
else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
|
|
33519
33566
|
return 89 /* CommandResult.InvalidHeaderIndex */;
|
|
33520
33567
|
}
|
|
33521
33568
|
else {
|
|
@@ -34309,8 +34356,8 @@
|
|
|
34309
34356
|
let newRange = range;
|
|
34310
34357
|
let changeType = "NONE";
|
|
34311
34358
|
for (let group of groups) {
|
|
34312
|
-
const min =
|
|
34313
|
-
const max =
|
|
34359
|
+
const min = largeMin(group);
|
|
34360
|
+
const max = largeMax(group);
|
|
34314
34361
|
if (range.zone[start] <= min && min <= range.zone[end]) {
|
|
34315
34362
|
const toRemove = Math.min(range.zone[end], max) - min + 1;
|
|
34316
34363
|
changeType = "RESIZE";
|
|
@@ -34737,7 +34784,7 @@
|
|
|
34737
34784
|
const elements = cmd.dimension === "COL"
|
|
34738
34785
|
? this.getNumberCols(cmd.sheetId)
|
|
34739
34786
|
: this.getNumberRows(cmd.sheetId);
|
|
34740
|
-
if (
|
|
34787
|
+
if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
|
|
34741
34788
|
return 89 /* CommandResult.InvalidHeaderIndex */;
|
|
34742
34789
|
}
|
|
34743
34790
|
else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
|
|
@@ -37613,13 +37660,13 @@
|
|
|
37613
37660
|
.map((cell) => cell.value);
|
|
37614
37661
|
switch (threshold.type) {
|
|
37615
37662
|
case "value":
|
|
37616
|
-
const result = functionName === "max" ?
|
|
37663
|
+
const result = functionName === "max" ? largeMax(rangeValues) : largeMin(rangeValues);
|
|
37617
37664
|
return result;
|
|
37618
37665
|
case "number":
|
|
37619
37666
|
return Number(threshold.value);
|
|
37620
37667
|
case "percentage":
|
|
37621
|
-
const min =
|
|
37622
|
-
const max =
|
|
37668
|
+
const min = largeMin(rangeValues);
|
|
37669
|
+
const max = largeMax(rangeValues);
|
|
37623
37670
|
const delta = max - min;
|
|
37624
37671
|
return min + (delta * Number(threshold.value)) / 100;
|
|
37625
37672
|
case "percentile":
|
|
@@ -38502,13 +38549,13 @@
|
|
|
38502
38549
|
const cells = this.getters.getEvaluatedCellsInZone(sheet.id, zone);
|
|
38503
38550
|
const cellPositions = range(end, -1, -1);
|
|
38504
38551
|
const invalidCells = cellPositions.filter((position) => cells[position] && !cells[position].isAutoSummable);
|
|
38505
|
-
const maxValidPosition =
|
|
38552
|
+
const maxValidPosition = largeMax(invalidCells);
|
|
38506
38553
|
const numberSequences = groupConsecutive(cellPositions.filter((position) => this.isNumber(cells[position])));
|
|
38507
38554
|
const firstSequence = numberSequences[0] || [];
|
|
38508
|
-
if (
|
|
38555
|
+
if (largeMax(firstSequence) < maxValidPosition) {
|
|
38509
38556
|
return Infinity;
|
|
38510
38557
|
}
|
|
38511
|
-
return
|
|
38558
|
+
return largeMin(firstSequence);
|
|
38512
38559
|
}
|
|
38513
38560
|
shouldFindData(sheetId, zone) {
|
|
38514
38561
|
return this.getters.isEmpty(sheetId, zone) || this.getters.isSingleCellOrMerge(sheetId, zone);
|
|
@@ -40097,7 +40144,7 @@
|
|
|
40097
40144
|
* column of the current viewport
|
|
40098
40145
|
*/
|
|
40099
40146
|
getColDimensionsInViewport(sheetId, col) {
|
|
40100
|
-
const left =
|
|
40147
|
+
const left = largeMin(this.getters.getSheetViewVisibleCols());
|
|
40101
40148
|
const start = this.getters.getColRowOffsetInViewport("COL", left, col);
|
|
40102
40149
|
const size = this.getters.getColSize(sheetId, col);
|
|
40103
40150
|
const isColHidden = this.getters.isColHidden(sheetId, col);
|
|
@@ -40112,7 +40159,7 @@
|
|
|
40112
40159
|
* of the current viewport
|
|
40113
40160
|
*/
|
|
40114
40161
|
getRowDimensionsInViewport(sheetId, row) {
|
|
40115
|
-
const top =
|
|
40162
|
+
const top = largeMin(this.getters.getSheetViewVisibleRows());
|
|
40116
40163
|
const start = this.getters.getColRowOffsetInViewport("ROW", top, row);
|
|
40117
40164
|
const size = this.getters.getRowSize(sheetId, row);
|
|
40118
40165
|
const isRowHidden = this.getters.isRowHidden(sheetId, row);
|
|
@@ -41609,7 +41656,7 @@
|
|
|
41609
41656
|
getColMaxWidth(sheetId, index) {
|
|
41610
41657
|
const cellsPositions = positions(this.getters.getColsZone(sheetId, index, index));
|
|
41611
41658
|
const sizes = cellsPositions.map((position) => this.getCellWidth({ sheetId, ...position }));
|
|
41612
|
-
return Math.max(0,
|
|
41659
|
+
return Math.max(0, largeMax(sizes));
|
|
41613
41660
|
}
|
|
41614
41661
|
/**
|
|
41615
41662
|
* Check that any "sheetId" in the command matches an existing
|
|
@@ -42911,7 +42958,7 @@
|
|
|
42911
42958
|
}
|
|
42912
42959
|
getPasteZone(target) {
|
|
42913
42960
|
const height = this.values.length;
|
|
42914
|
-
const width =
|
|
42961
|
+
const width = largeMax(this.values.map((a) => a.length));
|
|
42915
42962
|
const { left: activeCol, top: activeRow } = target[0];
|
|
42916
42963
|
return {
|
|
42917
42964
|
top: activeRow,
|
|
@@ -44397,6 +44444,7 @@
|
|
|
44397
44444
|
this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
|
|
44398
44445
|
this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
|
|
44399
44446
|
this.setSelectionMixin(this.gridSelection.anchor, this.gridSelection.zones);
|
|
44447
|
+
this.selectedFigureId = null;
|
|
44400
44448
|
break;
|
|
44401
44449
|
}
|
|
44402
44450
|
/** Any change to the selection has to be reflected in the selection processor. */
|
|
@@ -46131,12 +46179,14 @@
|
|
|
46131
46179
|
this.editionState = "initializing";
|
|
46132
46180
|
}
|
|
46133
46181
|
stopEdition() {
|
|
46134
|
-
|
|
46182
|
+
const input = this.sheetNameRef.el;
|
|
46183
|
+
if (!this.state.isEditing || !input)
|
|
46135
46184
|
return;
|
|
46136
46185
|
this.state.isEditing = false;
|
|
46137
46186
|
this.editionState = "initializing";
|
|
46138
|
-
|
|
46187
|
+
input.blur();
|
|
46139
46188
|
const inputValue = this.getInputContent() || "";
|
|
46189
|
+
input.innerText = inputValue;
|
|
46140
46190
|
interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
|
|
46141
46191
|
}
|
|
46142
46192
|
cancelEdition() {
|
|
@@ -46598,7 +46648,7 @@
|
|
|
46598
46648
|
this.sheetListRef.el.scrollTo({ top: 0, left: scroll, behavior: "smooth" });
|
|
46599
46649
|
}
|
|
46600
46650
|
onSheetMouseDown(sheetId, event) {
|
|
46601
|
-
if (event.button !== 0)
|
|
46651
|
+
if (event.button !== 0 || this.env.model.getters.isReadonly())
|
|
46602
46652
|
return;
|
|
46603
46653
|
this.closeMenu();
|
|
46604
46654
|
const mouseX = event.clientX;
|
|
@@ -49802,7 +49852,7 @@
|
|
|
49802
49852
|
}
|
|
49803
49853
|
function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
|
|
49804
49854
|
const colors = new ChartColors();
|
|
49805
|
-
const maxLength =
|
|
49855
|
+
const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
|
|
49806
49856
|
const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
|
|
49807
49857
|
const dataSetsNodes = [];
|
|
49808
49858
|
for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
|
|
@@ -51733,9 +51783,9 @@
|
|
|
51733
51783
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
51734
51784
|
|
|
51735
51785
|
|
|
51736
|
-
__info__.version = '16.4.
|
|
51737
|
-
__info__.date = '2024-
|
|
51738
|
-
__info__.hash = '
|
|
51786
|
+
__info__.version = '16.4.28';
|
|
51787
|
+
__info__.date = '2024-04-05T13:59:39.997Z';
|
|
51788
|
+
__info__.hash = '7127826';
|
|
51739
51789
|
|
|
51740
51790
|
|
|
51741
51791
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|