@odoo/o-spreadsheet 17.0.1 → 17.0.3
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 +137 -86
- package/dist/o-spreadsheet.d.ts +13 -8
- package/dist/o-spreadsheet.esm.js +136 -87
- package/dist/o-spreadsheet.iife.js +137 -86
- package/dist/o-spreadsheet.iife.min.js +253 -253
- 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 2023-11-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.3
|
|
6
|
+
* @date 2023-11-16T11:59:49.524Z
|
|
7
|
+
* @hash 8bd0fb2
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -4542,14 +4542,14 @@ function drawDecoratedText(context, text, position, underline = false, strikethr
|
|
|
4542
4542
|
switch (context.textBaseline) {
|
|
4543
4543
|
case "top":
|
|
4544
4544
|
underlineY += boxHeight - 2 * strokeWidth;
|
|
4545
|
-
strikeY += boxHeight -
|
|
4545
|
+
strikeY += boxHeight / 2 - strokeWidth;
|
|
4546
4546
|
break;
|
|
4547
4547
|
case "middle":
|
|
4548
4548
|
underlineY += boxHeight / 2 - strokeWidth;
|
|
4549
4549
|
break;
|
|
4550
4550
|
case "alphabetic":
|
|
4551
4551
|
underlineY += 2 * strokeWidth;
|
|
4552
|
-
strikeY -=
|
|
4552
|
+
strikeY -= 3 * strokeWidth;
|
|
4553
4553
|
break;
|
|
4554
4554
|
case "bottom":
|
|
4555
4555
|
underlineY = y;
|
|
@@ -5968,7 +5968,7 @@ autofillModifiersRegistry
|
|
|
5968
5968
|
return { cellData: {} };
|
|
5969
5969
|
}
|
|
5970
5970
|
const sheetId = data.sheetId;
|
|
5971
|
-
const content = getters.getTranslatedCellFormula(sheetId, x, y, cell.compiledFormula
|
|
5971
|
+
const content = getters.getTranslatedCellFormula(sheetId, x, y, cell.compiledFormula);
|
|
5972
5972
|
return {
|
|
5973
5973
|
cellData: {
|
|
5974
5974
|
border: data.border,
|
|
@@ -10695,6 +10695,17 @@ const SELECTION_CONTAINS_FILTER = (env) => {
|
|
|
10695
10695
|
const IS_ONLY_ONE_RANGE = (env) => {
|
|
10696
10696
|
return env.model.getters.getSelectedZones().length === 1;
|
|
10697
10697
|
};
|
|
10698
|
+
const CAN_INSERT_HEADER = (env, dimension) => {
|
|
10699
|
+
if (!IS_ONLY_ONE_RANGE(env)) {
|
|
10700
|
+
return false;
|
|
10701
|
+
}
|
|
10702
|
+
const activeHeaders = dimension === "COL" ? env.model.getters.getActiveCols() : env.model.getters.getActiveRows();
|
|
10703
|
+
const ortogonalActiveHeaders = dimension === "COL" ? env.model.getters.getActiveRows() : env.model.getters.getActiveCols();
|
|
10704
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
10705
|
+
const zone = env.model.getters.getSelectedZone();
|
|
10706
|
+
const allSheetSelected = isEqual(zone, env.model.getters.getSheetZone(sheetId));
|
|
10707
|
+
return isConsecutive(activeHeaders) && (ortogonalActiveHeaders.size === 0 || allSheetSelected);
|
|
10708
|
+
};
|
|
10698
10709
|
|
|
10699
10710
|
const undo = {
|
|
10700
10711
|
name: _t("Undo"),
|
|
@@ -19372,9 +19383,7 @@ const insertRow = {
|
|
|
19372
19383
|
const number = getRowsNumber(env);
|
|
19373
19384
|
return number === 1 ? _t("Insert row") : _t("Insert %s rows", number.toString());
|
|
19374
19385
|
},
|
|
19375
|
-
isVisible: (env) =>
|
|
19376
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19377
|
-
env.model.getters.getActiveCols().size === 0,
|
|
19386
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
19378
19387
|
icon: "o-spreadsheet-Icon.INSERT_ROW",
|
|
19379
19388
|
};
|
|
19380
19389
|
const rowInsertRowBefore = {
|
|
@@ -19383,9 +19392,7 @@ const rowInsertRowBefore = {
|
|
|
19383
19392
|
return number === 1 ? _t("Insert row above") : _t("Insert %s rows above", number.toString());
|
|
19384
19393
|
},
|
|
19385
19394
|
execute: INSERT_ROWS_BEFORE_ACTION,
|
|
19386
|
-
isVisible: (env) =>
|
|
19387
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19388
|
-
env.model.getters.getActiveCols().size === 0,
|
|
19395
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
19389
19396
|
icon: "o-spreadsheet-Icon.INSERT_ROW_BEFORE",
|
|
19390
19397
|
};
|
|
19391
19398
|
const topBarInsertRowsBefore = {
|
|
@@ -19416,9 +19423,7 @@ const rowInsertRowsAfter = {
|
|
|
19416
19423
|
const number = getRowsNumber(env);
|
|
19417
19424
|
return number === 1 ? _t("Insert row below") : _t("Insert %s rows below", number.toString());
|
|
19418
19425
|
},
|
|
19419
|
-
isVisible: (env) =>
|
|
19420
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19421
|
-
env.model.getters.getActiveCols().size === 0,
|
|
19426
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
19422
19427
|
icon: "o-spreadsheet-Icon.INSERT_ROW_AFTER",
|
|
19423
19428
|
};
|
|
19424
19429
|
const topBarInsertRowsAfter = {
|
|
@@ -19436,9 +19441,7 @@ const insertCol = {
|
|
|
19436
19441
|
const number = getColumnsNumber(env);
|
|
19437
19442
|
return number === 1 ? _t("Insert column") : _t("Insert %s columns", number.toString());
|
|
19438
19443
|
},
|
|
19439
|
-
isVisible: (env) =>
|
|
19440
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19441
|
-
env.model.getters.getActiveRows().size === 0,
|
|
19444
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
19442
19445
|
icon: "o-spreadsheet-Icon.INSERT_COL",
|
|
19443
19446
|
};
|
|
19444
19447
|
const colInsertColsBefore = {
|
|
@@ -19449,9 +19452,7 @@ const colInsertColsBefore = {
|
|
|
19449
19452
|
: _t("Insert %s columns left", number.toString());
|
|
19450
19453
|
},
|
|
19451
19454
|
execute: INSERT_COLUMNS_BEFORE_ACTION,
|
|
19452
|
-
isVisible: (env) =>
|
|
19453
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19454
|
-
env.model.getters.getActiveRows().size === 0,
|
|
19455
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
19455
19456
|
icon: "o-spreadsheet-Icon.INSERT_COL_BEFORE",
|
|
19456
19457
|
};
|
|
19457
19458
|
const topBarInsertColsBefore = {
|
|
@@ -19484,9 +19485,7 @@ const colInsertColsAfter = {
|
|
|
19484
19485
|
: _t("Insert %s columns right", number.toString());
|
|
19485
19486
|
},
|
|
19486
19487
|
execute: INSERT_COLUMNS_AFTER_ACTION,
|
|
19487
|
-
isVisible: (env) =>
|
|
19488
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
19489
|
-
env.model.getters.getActiveRows().size === 0,
|
|
19488
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
19490
19489
|
icon: "o-spreadsheet-Icon.INSERT_COL_AFTER",
|
|
19491
19490
|
};
|
|
19492
19491
|
const topBarInsertColsAfter = {
|
|
@@ -23827,7 +23826,7 @@ css /* scss */ `
|
|
|
23827
23826
|
}
|
|
23828
23827
|
.o-input-count {
|
|
23829
23828
|
width: fit-content;
|
|
23830
|
-
padding:
|
|
23829
|
+
padding: 4px 0 4px 4px;
|
|
23831
23830
|
}
|
|
23832
23831
|
}
|
|
23833
23832
|
}
|
|
@@ -34948,6 +34947,9 @@ const functionCache = {};
|
|
|
34948
34947
|
// -----------------------------------------------------------------------------
|
|
34949
34948
|
function compile(formula) {
|
|
34950
34949
|
const tokens = rangeTokenize(formula);
|
|
34950
|
+
return compileTokens(tokens);
|
|
34951
|
+
}
|
|
34952
|
+
function compileTokens(tokens) {
|
|
34951
34953
|
const { dependencies, constantValues } = formulaArguments(tokens);
|
|
34952
34954
|
const cacheKey = compilationCacheKey(tokens, dependencies, constantValues);
|
|
34953
34955
|
if (!functionCache[cacheKey]) {
|
|
@@ -35314,11 +35316,11 @@ class CellPlugin extends CorePlugin {
|
|
|
35314
35316
|
for (const sheet of Object.keys(this.cells)) {
|
|
35315
35317
|
for (const cell of Object.values(this.cells[sheet] || {})) {
|
|
35316
35318
|
if (cell.isFormula) {
|
|
35317
|
-
for (const range of cell.dependencies) {
|
|
35319
|
+
for (const range of cell.compiledFormula.dependencies) {
|
|
35318
35320
|
if (!sheetId || range.sheetId === sheetId) {
|
|
35319
35321
|
const change = applyChange(range);
|
|
35320
35322
|
if (change.changeType !== "NONE") {
|
|
35321
|
-
this.history.update("cells", sheet, cell.id, "dependencies", cell.dependencies.indexOf(range), change.range);
|
|
35323
|
+
this.history.update("cells", sheet, cell.id, "compiledFormula", "dependencies", cell.compiledFormula.dependencies.indexOf(range), change.range);
|
|
35322
35324
|
}
|
|
35323
35325
|
}
|
|
35324
35326
|
}
|
|
@@ -35514,10 +35516,10 @@ class CellPlugin extends CorePlugin {
|
|
|
35514
35516
|
/*
|
|
35515
35517
|
* Reconstructs the original formula string based on a normalized form and its dependencies
|
|
35516
35518
|
*/
|
|
35517
|
-
getFormulaCellContent(sheetId,
|
|
35518
|
-
const ranges = dependencies ||
|
|
35519
|
+
getFormulaCellContent(sheetId, compiledFormula, dependencies) {
|
|
35520
|
+
const ranges = dependencies || compiledFormula.dependencies;
|
|
35519
35521
|
let rangeIndex = 0;
|
|
35520
|
-
return concat(
|
|
35522
|
+
return concat(compiledFormula.tokens.map((token) => {
|
|
35521
35523
|
if (token.type === "REFERENCE") {
|
|
35522
35524
|
const range = ranges[rangeIndex++];
|
|
35523
35525
|
return this.getters.getRangeString(range, sheetId);
|
|
@@ -35528,12 +35530,9 @@ class CellPlugin extends CorePlugin {
|
|
|
35528
35530
|
/*
|
|
35529
35531
|
* Constructs a formula string based on an initial formula and a translation vector
|
|
35530
35532
|
*/
|
|
35531
|
-
getTranslatedCellFormula(sheetId, offsetX, offsetY, compiledFormula
|
|
35532
|
-
const adaptedDependencies = this.getters.createAdaptedRanges(dependencies, offsetX, offsetY, sheetId);
|
|
35533
|
-
return this.getFormulaCellContent(sheetId,
|
|
35534
|
-
compiledFormula,
|
|
35535
|
-
dependencies: adaptedDependencies,
|
|
35536
|
-
});
|
|
35533
|
+
getTranslatedCellFormula(sheetId, offsetX, offsetY, compiledFormula) {
|
|
35534
|
+
const adaptedDependencies = this.getters.createAdaptedRanges(compiledFormula.dependencies, offsetX, offsetY, sheetId);
|
|
35535
|
+
return this.getFormulaCellContent(sheetId, compiledFormula, adaptedDependencies);
|
|
35537
35536
|
}
|
|
35538
35537
|
getCellStyle(position) {
|
|
35539
35538
|
return this.getters.getCell(position)?.style || {};
|
|
@@ -35713,8 +35712,10 @@ class CellPlugin extends CorePlugin {
|
|
|
35713
35712
|
style,
|
|
35714
35713
|
format,
|
|
35715
35714
|
isFormula: true,
|
|
35716
|
-
compiledFormula
|
|
35717
|
-
|
|
35715
|
+
compiledFormula: {
|
|
35716
|
+
...compiledFormula,
|
|
35717
|
+
dependencies: [],
|
|
35718
|
+
},
|
|
35718
35719
|
};
|
|
35719
35720
|
}
|
|
35720
35721
|
/**
|
|
@@ -35723,7 +35724,7 @@ class CellPlugin extends CorePlugin {
|
|
|
35723
35724
|
*/
|
|
35724
35725
|
createFormulaCellWithDependencies(id, compiledFormula, format, style, sheetId) {
|
|
35725
35726
|
const dependencies = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
|
|
35726
|
-
return new FormulaCellWithDependencies(id, compiledFormula, format, style, dependencies, sheetId, this.
|
|
35727
|
+
return new FormulaCellWithDependencies(id, compiledFormula, format, style, dependencies, sheetId, this.getters.getRangeString.bind(this));
|
|
35727
35728
|
}
|
|
35728
35729
|
createErrorFormula(id, content, format, style, error) {
|
|
35729
35730
|
return {
|
|
@@ -35733,13 +35734,12 @@ class CellPlugin extends CorePlugin {
|
|
|
35733
35734
|
format,
|
|
35734
35735
|
isFormula: true,
|
|
35735
35736
|
compiledFormula: {
|
|
35736
|
-
dependencies: [],
|
|
35737
35737
|
tokens: tokenize(content),
|
|
35738
|
+
dependencies: [],
|
|
35738
35739
|
execute: function () {
|
|
35739
35740
|
throw error;
|
|
35740
35741
|
},
|
|
35741
35742
|
},
|
|
35742
|
-
dependencies: [],
|
|
35743
35743
|
};
|
|
35744
35744
|
}
|
|
35745
35745
|
checkCellOutOfSheet(sheetId, col, row) {
|
|
@@ -35752,27 +35752,44 @@ class CellPlugin extends CorePlugin {
|
|
|
35752
35752
|
}
|
|
35753
35753
|
class FormulaCellWithDependencies {
|
|
35754
35754
|
id;
|
|
35755
|
-
compiledFormula;
|
|
35756
35755
|
format;
|
|
35757
35756
|
style;
|
|
35758
|
-
dependencies;
|
|
35759
35757
|
sheetId;
|
|
35760
|
-
|
|
35758
|
+
getRangeString;
|
|
35761
35759
|
isFormula = true;
|
|
35762
|
-
|
|
35760
|
+
compiledFormula;
|
|
35761
|
+
constructor(id, compiledFormula, format, style, dependencies, sheetId, getRangeString) {
|
|
35763
35762
|
this.id = id;
|
|
35764
|
-
this.compiledFormula = compiledFormula;
|
|
35765
35763
|
this.format = format;
|
|
35766
35764
|
this.style = style;
|
|
35767
|
-
this.dependencies = dependencies;
|
|
35768
35765
|
this.sheetId = sheetId;
|
|
35769
|
-
this.
|
|
35766
|
+
this.getRangeString = getRangeString;
|
|
35767
|
+
let rangeIndex = 0;
|
|
35768
|
+
const tokens = compiledFormula.tokens.map((token) => {
|
|
35769
|
+
if (token.type === "REFERENCE") {
|
|
35770
|
+
const index = rangeIndex++;
|
|
35771
|
+
return new RangeReferenceToken(() => this.getRangeString(dependencies[index], this.sheetId));
|
|
35772
|
+
}
|
|
35773
|
+
return token;
|
|
35774
|
+
});
|
|
35775
|
+
this.compiledFormula = {
|
|
35776
|
+
...compiledFormula,
|
|
35777
|
+
dependencies,
|
|
35778
|
+
tokens,
|
|
35779
|
+
};
|
|
35770
35780
|
}
|
|
35771
35781
|
get content() {
|
|
35772
|
-
return this.
|
|
35773
|
-
|
|
35774
|
-
|
|
35775
|
-
|
|
35782
|
+
return concat(this.compiledFormula.tokens.map((token) => token.value));
|
|
35783
|
+
}
|
|
35784
|
+
}
|
|
35785
|
+
class RangeReferenceToken {
|
|
35786
|
+
getValue;
|
|
35787
|
+
type = "REFERENCE";
|
|
35788
|
+
constructor(getValue) {
|
|
35789
|
+
this.getValue = getValue;
|
|
35790
|
+
}
|
|
35791
|
+
get value() {
|
|
35792
|
+
return this.getValue();
|
|
35776
35793
|
}
|
|
35777
35794
|
}
|
|
35778
35795
|
|
|
@@ -36917,6 +36934,13 @@ class FiltersPlugin extends CorePlugin {
|
|
|
36917
36934
|
}
|
|
36918
36935
|
onDeleteColumnsRows(cmd) {
|
|
36919
36936
|
for (const table of this.getFilterTables(cmd.sheetId)) {
|
|
36937
|
+
// Remove the filter tables whose data filter headers are in the removed rows.
|
|
36938
|
+
if (cmd.dimension === "ROW" && cmd.elements.includes(table.zone.top)) {
|
|
36939
|
+
const tables = { ...this.tables[cmd.sheetId] };
|
|
36940
|
+
delete tables[table.id];
|
|
36941
|
+
this.history.update("tables", cmd.sheetId, tables);
|
|
36942
|
+
continue;
|
|
36943
|
+
}
|
|
36920
36944
|
const zone = reduceZoneOnDeletion(table.zone, cmd.dimension === "COL" ? "left" : "top", cmd.elements);
|
|
36921
36945
|
if (!zone) {
|
|
36922
36946
|
const tables = { ...this.tables[cmd.sheetId] };
|
|
@@ -39965,6 +39989,13 @@ class Evaluator {
|
|
|
39965
39989
|
return (this.evaluatedCells.get(this.encodePosition(position)) ||
|
|
39966
39990
|
createEvaluatedCell("", { locale: this.getters.getLocale() }));
|
|
39967
39991
|
}
|
|
39992
|
+
getSpreadPositionsOf(position) {
|
|
39993
|
+
const positionId = this.encodePosition(position);
|
|
39994
|
+
if (!this.spreadingRelations.isArrayFormula(positionId)) {
|
|
39995
|
+
return [];
|
|
39996
|
+
}
|
|
39997
|
+
return Array.from(this.spreadingRelations.getArrayResultPositionIds(positionId)).map(this.decodePosition.bind(this));
|
|
39998
|
+
}
|
|
39968
39999
|
getArrayFormulaSpreadingOn(position) {
|
|
39969
40000
|
const positionId = this.encodePosition(position);
|
|
39970
40001
|
const formulaPosition = this.getArrayFormulaSpreadingOnId(positionId);
|
|
@@ -40069,9 +40100,6 @@ class Evaluator {
|
|
|
40069
40100
|
}
|
|
40070
40101
|
}
|
|
40071
40102
|
setEvaluatedCell(positionId, evaluatedCell) {
|
|
40072
|
-
if (this.nextPositionsToUpdate.has(positionId)) {
|
|
40073
|
-
this.nextPositionsToUpdate.delete(positionId);
|
|
40074
|
-
}
|
|
40075
40103
|
this.evaluatedCells.set(positionId, evaluatedCell);
|
|
40076
40104
|
}
|
|
40077
40105
|
computeCell(positionId) {
|
|
@@ -40126,7 +40154,7 @@ class Evaluator {
|
|
|
40126
40154
|
const position = this.compilationParams[2].getters.getCellPosition(cellId);
|
|
40127
40155
|
return toXC(position.col, position.row);
|
|
40128
40156
|
};
|
|
40129
|
-
const formulaReturn = cellData.compiledFormula.execute(cellData.dependencies, ...this.compilationParams);
|
|
40157
|
+
const formulaReturn = cellData.compiledFormula.execute(cellData.compiledFormula.dependencies, ...this.compilationParams);
|
|
40130
40158
|
if (!isMatrix(formulaReturn)) {
|
|
40131
40159
|
return createEvaluatedCell(formulaReturn.value, {
|
|
40132
40160
|
format: cellData.format || formulaReturn.format,
|
|
@@ -40226,7 +40254,7 @@ class Evaluator {
|
|
|
40226
40254
|
return [];
|
|
40227
40255
|
}
|
|
40228
40256
|
const dependencies = [];
|
|
40229
|
-
for (const range of cell.dependencies) {
|
|
40257
|
+
for (const range of cell.compiledFormula.dependencies) {
|
|
40230
40258
|
if (range.invalidSheetName || range.invalidXc) {
|
|
40231
40259
|
continue;
|
|
40232
40260
|
}
|
|
@@ -40432,6 +40460,7 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
40432
40460
|
"getEvaluatedCell",
|
|
40433
40461
|
"getEvaluatedCells",
|
|
40434
40462
|
"getEvaluatedCellsInZone",
|
|
40463
|
+
"getSpreadPositionsOf",
|
|
40435
40464
|
];
|
|
40436
40465
|
shouldRebuildDependenciesGraph = true;
|
|
40437
40466
|
evaluator;
|
|
@@ -40541,6 +40570,9 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
40541
40570
|
getEvaluatedCellsInZone(sheetId, zone) {
|
|
40542
40571
|
return positions(zone).map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId, col, row }));
|
|
40543
40572
|
}
|
|
40573
|
+
getSpreadPositionsOf(position) {
|
|
40574
|
+
return this.evaluator.getSpreadPositionsOf(position);
|
|
40575
|
+
}
|
|
40544
40576
|
// ---------------------------------------------------------------------------
|
|
40545
40577
|
// Export
|
|
40546
40578
|
// ---------------------------------------------------------------------------
|
|
@@ -40578,10 +40610,10 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
40578
40610
|
*/
|
|
40579
40611
|
getCorrespondingFormulaCell(position) {
|
|
40580
40612
|
const cell = this.getters.getCell(position);
|
|
40581
|
-
if (cell && cell.
|
|
40582
|
-
|
|
40583
|
-
|
|
40584
|
-
|
|
40613
|
+
if (cell && cell.isFormula) {
|
|
40614
|
+
return isBadExpression(cell.compiledFormula.tokens) ? undefined : cell;
|
|
40615
|
+
}
|
|
40616
|
+
else if (cell && cell.content) {
|
|
40585
40617
|
return undefined;
|
|
40586
40618
|
}
|
|
40587
40619
|
const spreadingFormulaPosition = this.evaluator.getArrayFormulaSpreadingOn(position);
|
|
@@ -40598,9 +40630,9 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
40598
40630
|
return buildCompilationParameters(this.config.custom, this.getters, (position) => this.evaluator.getEvaluatedCell(position));
|
|
40599
40631
|
}
|
|
40600
40632
|
}
|
|
40601
|
-
function isBadExpression(
|
|
40633
|
+
function isBadExpression(tokens) {
|
|
40602
40634
|
try {
|
|
40603
|
-
|
|
40635
|
+
compileTokens(tokens);
|
|
40604
40636
|
return false;
|
|
40605
40637
|
}
|
|
40606
40638
|
catch (error) {
|
|
@@ -40769,22 +40801,20 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
40769
40801
|
invalidateCFEvaluationCommands.has(cmd.type) ||
|
|
40770
40802
|
cmd.type === "EVALUATE_CELLS" ||
|
|
40771
40803
|
cmd.type === "UPDATE_CELL") {
|
|
40772
|
-
|
|
40773
|
-
|
|
40774
|
-
this.history.update("charts", chartId, undefined);
|
|
40775
|
-
}
|
|
40804
|
+
for (const chartId in this.charts) {
|
|
40805
|
+
this.charts[chartId] = undefined;
|
|
40776
40806
|
}
|
|
40777
40807
|
}
|
|
40778
40808
|
switch (cmd.type) {
|
|
40779
40809
|
case "UPDATE_CHART":
|
|
40780
40810
|
case "CREATE_CHART":
|
|
40781
40811
|
case "DELETE_FIGURE":
|
|
40782
|
-
this.
|
|
40812
|
+
this.charts[cmd.id] = undefined;
|
|
40783
40813
|
break;
|
|
40784
40814
|
case "DELETE_SHEET":
|
|
40785
40815
|
for (let chartId in this.charts) {
|
|
40786
40816
|
if (!this.getters.isChartDefined(chartId)) {
|
|
40787
|
-
this.
|
|
40817
|
+
this.charts[chartId] = undefined;
|
|
40788
40818
|
}
|
|
40789
40819
|
}
|
|
40790
40820
|
break;
|
|
@@ -40796,8 +40826,7 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
40796
40826
|
if (!chart) {
|
|
40797
40827
|
throw new Error(`No chart for the given id: ${figureId}`);
|
|
40798
40828
|
}
|
|
40799
|
-
|
|
40800
|
-
this.history.update("charts", figureId, runtime);
|
|
40829
|
+
this.charts[figureId] = this.createRuntimeChart(chart);
|
|
40801
40830
|
}
|
|
40802
40831
|
return this.charts[figureId];
|
|
40803
40832
|
}
|
|
@@ -40949,7 +40978,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
40949
40978
|
const values = cf.rule.values.map((value, i) => {
|
|
40950
40979
|
const compiledFormula = formulas[i];
|
|
40951
40980
|
if (compiledFormula) {
|
|
40952
|
-
return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top,
|
|
40981
|
+
return this.getters.getTranslatedCellFormula(sheetId, col - zone.left, row - zone.top, {
|
|
40982
|
+
...compiledFormula,
|
|
40983
|
+
dependencies: compiledFormula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
|
|
40984
|
+
});
|
|
40953
40985
|
}
|
|
40954
40986
|
return value;
|
|
40955
40987
|
});
|
|
@@ -41321,7 +41353,10 @@ class EvaluationDataValidationPlugin extends UIPlugin {
|
|
|
41321
41353
|
}
|
|
41322
41354
|
try {
|
|
41323
41355
|
const formula = compile(value);
|
|
41324
|
-
const translatedFormula = this.getters.getTranslatedCellFormula(sheetId, offset.col, offset.row,
|
|
41356
|
+
const translatedFormula = this.getters.getTranslatedCellFormula(sheetId, offset.col, offset.row, {
|
|
41357
|
+
...formula,
|
|
41358
|
+
dependencies: formula.dependencies.map((d) => this.getters.getRangeFromSheetXC(sheetId, d)),
|
|
41359
|
+
});
|
|
41325
41360
|
const evaluated = this.getters.evaluateFormula(sheetId, translatedFormula);
|
|
41326
41361
|
return evaluated && !isMatrix(evaluated) ? evaluated.toString() : "";
|
|
41327
41362
|
}
|
|
@@ -43573,7 +43608,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
43573
43608
|
}
|
|
43574
43609
|
let content = origin.cell.content;
|
|
43575
43610
|
if (origin.cell.isFormula && operation === "COPY") {
|
|
43576
|
-
content = this.getters.getTranslatedCellFormula(sheetId, col - origin.position.col, row - origin.position.row, origin.cell.compiledFormula
|
|
43611
|
+
content = this.getters.getTranslatedCellFormula(sheetId, col - origin.position.col, row - origin.position.row, origin.cell.compiledFormula);
|
|
43577
43612
|
}
|
|
43578
43613
|
this.dispatch("UPDATE_CELL", {
|
|
43579
43614
|
...target,
|
|
@@ -44105,20 +44140,29 @@ class FindAndReplacePlugin extends UIPlugin {
|
|
|
44105
44140
|
const sheetId = this.getters.getActiveSheetId();
|
|
44106
44141
|
const cells = this.getters.getCells(sheetId);
|
|
44107
44142
|
const matches = [];
|
|
44108
|
-
if (this.toSearch) {
|
|
44143
|
+
if (this.toSearch && this.currentSearchRegex) {
|
|
44109
44144
|
for (const cell of Object.values(cells)) {
|
|
44110
44145
|
const { col, row } = this.getters.getCellPosition(cell.id);
|
|
44146
|
+
const cellPosition = { sheetId, col, row };
|
|
44111
44147
|
const isColHidden = this.getters.isColHidden(sheetId, col);
|
|
44112
44148
|
const isRowHidden = this.getters.isRowHidden(sheetId, row);
|
|
44113
44149
|
if (isColHidden || isRowHidden) {
|
|
44114
44150
|
continue;
|
|
44115
44151
|
}
|
|
44116
|
-
if (
|
|
44117
|
-
this.currentSearchRegex &&
|
|
44118
|
-
this.currentSearchRegex.test(this.getSearchableString({ sheetId, col, row }))) {
|
|
44152
|
+
if (this.currentSearchRegex.test(this.getSearchableString(cellPosition))) {
|
|
44119
44153
|
const match = { col, row, selected: false };
|
|
44120
44154
|
matches.push(match);
|
|
44121
44155
|
}
|
|
44156
|
+
for (const spreadPosition of this.getters.getSpreadPositionsOf(cellPosition)) {
|
|
44157
|
+
if (this.currentSearchRegex.test(this.getSearchableString(spreadPosition))) {
|
|
44158
|
+
const match = {
|
|
44159
|
+
col: spreadPosition.col,
|
|
44160
|
+
row: spreadPosition.row,
|
|
44161
|
+
selected: false,
|
|
44162
|
+
};
|
|
44163
|
+
matches.push(match);
|
|
44164
|
+
}
|
|
44165
|
+
}
|
|
44122
44166
|
}
|
|
44123
44167
|
}
|
|
44124
44168
|
return matches.sort(this.sortByRowThenColumn);
|
|
@@ -44177,16 +44221,19 @@ class FindAndReplacePlugin extends UIPlugin {
|
|
|
44177
44221
|
return;
|
|
44178
44222
|
}
|
|
44179
44223
|
const sheetId = this.getters.getActiveSheetId();
|
|
44180
|
-
const
|
|
44181
|
-
const
|
|
44224
|
+
const position = { sheetId, ...selectedMatch };
|
|
44225
|
+
const cell = this.getters.getCell(position);
|
|
44226
|
+
if (!cell?.content) {
|
|
44227
|
+
return;
|
|
44228
|
+
}
|
|
44182
44229
|
if (cell?.isFormula && !this.searchOptions.searchFormulas) {
|
|
44183
44230
|
return;
|
|
44184
44231
|
}
|
|
44185
44232
|
const replaceRegex = new RegExp(this.currentSearchRegex.source, this.currentSearchRegex.flags + "g");
|
|
44186
|
-
const toReplace = this.getSearchableString(
|
|
44233
|
+
const toReplace = this.getSearchableString(position);
|
|
44187
44234
|
const content = toReplace.replace(replaceRegex, replaceWith);
|
|
44188
44235
|
const canonicalContent = canonicalizeNumberContent(content, this.getters.getLocale());
|
|
44189
|
-
this.dispatch("UPDATE_CELL", {
|
|
44236
|
+
this.dispatch("UPDATE_CELL", { ...position, content: canonicalContent });
|
|
44190
44237
|
}
|
|
44191
44238
|
/**
|
|
44192
44239
|
* Replace the value of the currently selected match
|
|
@@ -45761,7 +45808,7 @@ class SortPlugin extends UIPlugin {
|
|
|
45761
45808
|
if (cell.isFormula) {
|
|
45762
45809
|
const position = this.getters.getCellPosition(cell.id);
|
|
45763
45810
|
// we only have a vertical offset
|
|
45764
|
-
content = this.getters.getTranslatedCellFormula(sheetId, 0, newRow - position.row, cell.compiledFormula
|
|
45811
|
+
content = this.getters.getTranslatedCellFormula(sheetId, 0, newRow - position.row, cell.compiledFormula);
|
|
45765
45812
|
}
|
|
45766
45813
|
newCellValues.style = cell.style;
|
|
45767
45814
|
newCellValues.content = content;
|
|
@@ -47824,6 +47871,8 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
47824
47871
|
case "EVALUATE_CELLS":
|
|
47825
47872
|
case "ACTIVATE_SHEET":
|
|
47826
47873
|
case "REMOVE_FILTER_TABLE":
|
|
47874
|
+
case "ADD_COLUMNS_ROWS":
|
|
47875
|
+
case "REMOVE_COLUMNS_ROWS":
|
|
47827
47876
|
this.isEvaluationDirty = true;
|
|
47828
47877
|
break;
|
|
47829
47878
|
case "START":
|
|
@@ -55847,6 +55896,7 @@ exports.__info__ = __info__;
|
|
|
55847
55896
|
exports.addFunction = addFunction;
|
|
55848
55897
|
exports.astToFormula = astToFormula;
|
|
55849
55898
|
exports.compile = compile;
|
|
55899
|
+
exports.compileTokens = compileTokens;
|
|
55850
55900
|
exports.components = components;
|
|
55851
55901
|
exports.constants = constants;
|
|
55852
55902
|
exports.convertAstNodes = convertAstNodes;
|
|
@@ -55862,6 +55912,7 @@ exports.iterateAstNodes = iterateAstNodes;
|
|
|
55862
55912
|
exports.links = links;
|
|
55863
55913
|
exports.load = load;
|
|
55864
55914
|
exports.parse = parse;
|
|
55915
|
+
exports.parseTokens = parseTokens;
|
|
55865
55916
|
exports.readonlyAllowedCommands = readonlyAllowedCommands;
|
|
55866
55917
|
exports.registries = registries;
|
|
55867
55918
|
exports.setDefaultSheetViewSize = setDefaultSheetViewSize;
|
|
@@ -55869,6 +55920,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
55869
55920
|
exports.tokenize = tokenize;
|
|
55870
55921
|
|
|
55871
55922
|
|
|
55872
|
-
__info__.version = "17.0.
|
|
55873
|
-
__info__.date = "2023-11-
|
|
55874
|
-
__info__.hash = "
|
|
55923
|
+
__info__.version = "17.0.3";
|
|
55924
|
+
__info__.date = "2023-11-16T11:59:49.524Z";
|
|
55925
|
+
__info__.hash = "8bd0fb2";
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const functionCache: {
|
|
|
17
17
|
[key: string]: Omit<CompiledFormula, "dependencies" | "tokens">;
|
|
18
18
|
};
|
|
19
19
|
declare function compile(formula: string): CompiledFormula;
|
|
20
|
+
declare function compileTokens(tokens: Token[]): CompiledFormula;
|
|
20
21
|
|
|
21
22
|
interface FunctionContext {
|
|
22
23
|
parent: string;
|
|
@@ -93,6 +94,7 @@ type AST = ASTOperation | ASTUnaryOperation | ASTFuncall | ASTNumber | ASTBoolea
|
|
|
93
94
|
* Parse an expression (as a string) into an AST.
|
|
94
95
|
*/
|
|
95
96
|
declare function parse(str: string): AST;
|
|
97
|
+
declare function parseTokens(tokens: Token[]): AST;
|
|
96
98
|
/**
|
|
97
99
|
* Allows to visit all nodes of an AST and apply a mapping function
|
|
98
100
|
* to nodes of a specific type.
|
|
@@ -2652,6 +2654,9 @@ interface CompiledFormula {
|
|
|
2652
2654
|
tokens: Token[];
|
|
2653
2655
|
dependencies: string[];
|
|
2654
2656
|
}
|
|
2657
|
+
interface RangeCompiledFormula extends Omit<CompiledFormula, "dependencies"> {
|
|
2658
|
+
dependencies: Range[];
|
|
2659
|
+
}
|
|
2655
2660
|
type Matrix<T = unknown> = T[][];
|
|
2656
2661
|
type ValueAndFormat = {
|
|
2657
2662
|
value: CellValue;
|
|
@@ -2803,8 +2808,7 @@ interface LiteralCell extends CellAttributes {
|
|
|
2803
2808
|
}
|
|
2804
2809
|
interface FormulaCell extends CellAttributes {
|
|
2805
2810
|
readonly isFormula: true;
|
|
2806
|
-
readonly compiledFormula:
|
|
2807
|
-
readonly dependencies: Range[];
|
|
2811
|
+
readonly compiledFormula: RangeCompiledFormula;
|
|
2808
2812
|
}
|
|
2809
2813
|
type Cell = LiteralCell | FormulaCell;
|
|
2810
2814
|
interface EvaluatedCellProperties {
|
|
@@ -3378,8 +3382,8 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
|
|
|
3378
3382
|
* starting an async evaluation even if it has been moved or re-allocated
|
|
3379
3383
|
*/
|
|
3380
3384
|
getCellById(cellId: UID): Cell | undefined;
|
|
3381
|
-
getFormulaCellContent(sheetId: UID,
|
|
3382
|
-
getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula:
|
|
3385
|
+
getFormulaCellContent(sheetId: UID, compiledFormula: RangeCompiledFormula, dependencies?: Range[]): string;
|
|
3386
|
+
getTranslatedCellFormula(sheetId: UID, offsetX: number, offsetY: number, compiledFormula: RangeCompiledFormula): string;
|
|
3383
3387
|
getCellStyle(position: CellPosition): Style;
|
|
3384
3388
|
/**
|
|
3385
3389
|
* Converts a zone to a XC coordinate system
|
|
@@ -4084,7 +4088,7 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
|
|
|
4084
4088
|
|
|
4085
4089
|
declare class EvaluationPlugin extends UIPlugin {
|
|
4086
4090
|
private config;
|
|
4087
|
-
static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone"];
|
|
4091
|
+
static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf"];
|
|
4088
4092
|
private shouldRebuildDependenciesGraph;
|
|
4089
4093
|
private evaluator;
|
|
4090
4094
|
private compilationParams;
|
|
@@ -4109,6 +4113,7 @@ declare class EvaluationPlugin extends UIPlugin {
|
|
|
4109
4113
|
getEvaluatedCell(position: CellPosition): EvaluatedCell;
|
|
4110
4114
|
getEvaluatedCells(sheetId: UID): Record<UID, EvaluatedCell>;
|
|
4111
4115
|
getEvaluatedCellsInZone(sheetId: UID, zone: Zone): EvaluatedCell[];
|
|
4116
|
+
getSpreadPositionsOf(position: CellPosition): CellPosition[];
|
|
4112
4117
|
exportForExcel(data: ExcelWorkbookData): void;
|
|
4113
4118
|
/**
|
|
4114
4119
|
* Returns the corresponding formula cell of a given cell
|
|
@@ -4142,11 +4147,11 @@ declare class CustomColorsPlugin extends UIPlugin<CustomColorState> {
|
|
|
4142
4147
|
}
|
|
4143
4148
|
|
|
4144
4149
|
interface EvaluationChartState {
|
|
4145
|
-
|
|
4150
|
+
charts: Record<UID, ChartRuntime | undefined>;
|
|
4146
4151
|
}
|
|
4147
4152
|
declare class EvaluationChartPlugin extends UIPlugin<EvaluationChartState> {
|
|
4148
4153
|
static getters: readonly ["getChartRuntime", "getBackgroundOfSingleCellChart"];
|
|
4149
|
-
|
|
4154
|
+
charts: Record<UID, ChartRuntime | undefined>;
|
|
4150
4155
|
private createRuntimeChart;
|
|
4151
4156
|
handle(cmd: CoreViewCommand): void;
|
|
4152
4157
|
getChartRuntime(figureId: UID): ChartRuntime;
|
|
@@ -7908,4 +7913,4 @@ declare const constants: {
|
|
|
7908
7913
|
DEFAULT_LOCALE: Locale;
|
|
7909
7914
|
};
|
|
7910
7915
|
|
|
7911
|
-
export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
|
|
7916
|
+
export { AbstractChart, CancelledReason, Client, ClientJoinedMessage, ClientLeftMessage, ClientMovedMessage, CollaborationMessage, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, RemoteRevisionMessage, Revision, RevisionRedoneMessage, RevisionUndoneMessage, SPREADSHEET_DIMENSIONS, Spreadsheet, TransportService, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
|