@odoo/o-spreadsheet 15.2.14 → 15.2.16
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 +57 -55
- package/dist/o-spreadsheet.esm.js +57 -55
- package/dist/o-spreadsheet.iife.js +57 -55
- package/dist/o-spreadsheet.iife.min.js +2 -2
- package/package.json +1 -1
|
@@ -18786,13 +18786,18 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18786
18786
|
// Getters
|
|
18787
18787
|
// ---------------------------------------------------------------------------
|
|
18788
18788
|
evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
|
|
18789
|
-
|
|
18790
|
-
|
|
18791
|
-
|
|
18792
|
-
|
|
18793
|
-
|
|
18789
|
+
try {
|
|
18790
|
+
const compiledFormula = compile(formulaString);
|
|
18791
|
+
const params = this.getFormulaParameters(() => { });
|
|
18792
|
+
const ranges = [];
|
|
18793
|
+
for (let xc of compiledFormula.dependencies) {
|
|
18794
|
+
ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
|
|
18795
|
+
}
|
|
18796
|
+
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18797
|
+
}
|
|
18798
|
+
catch {
|
|
18799
|
+
return "#ERROR";
|
|
18794
18800
|
}
|
|
18795
|
-
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18796
18801
|
}
|
|
18797
18802
|
/**
|
|
18798
18803
|
* Return the value of each cell in the range as they are displayed in the grid.
|
|
@@ -18904,10 +18909,8 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18904
18909
|
* that are actually present in the grid.
|
|
18905
18910
|
*/
|
|
18906
18911
|
function _range(range) {
|
|
18912
|
+
assertRangeValid(range);
|
|
18907
18913
|
const sheetId = range.sheetId;
|
|
18908
|
-
if (!isZoneValid(range.zone)) {
|
|
18909
|
-
throw new Error(_lt("Invalid reference"));
|
|
18910
|
-
}
|
|
18911
18914
|
// Performance issue: Avoid fetching data on positions that are out of the spreadsheet
|
|
18912
18915
|
// e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
|
|
18913
18916
|
const sheetZone = {
|
|
@@ -18946,21 +18949,16 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18946
18949
|
*/
|
|
18947
18950
|
function refFn(position, references, sheetId, isMeta, functionName, paramNumber) {
|
|
18948
18951
|
const range = references[position];
|
|
18952
|
+
assertRangeValid(range);
|
|
18949
18953
|
if (isMeta) {
|
|
18950
18954
|
return evalContext.getters.getRangeString(range, sheetId);
|
|
18951
18955
|
}
|
|
18952
|
-
if (!isZoneValid(range.zone)) {
|
|
18953
|
-
throw new Error(_lt("Invalid reference"));
|
|
18954
|
-
}
|
|
18955
18956
|
// if the formula definition could have accepted a range, we would pass through the _range function and not here
|
|
18956
18957
|
if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
|
|
18957
18958
|
throw new Error(paramNumber
|
|
18958
18959
|
? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
|
|
18959
18960
|
: _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
|
|
18960
18961
|
}
|
|
18961
|
-
if (range.invalidSheetName) {
|
|
18962
|
-
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18963
|
-
}
|
|
18964
18962
|
return readCell(range);
|
|
18965
18963
|
}
|
|
18966
18964
|
/**
|
|
@@ -18973,6 +18971,14 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18973
18971
|
function range(position, references, sheetId) {
|
|
18974
18972
|
return _range(references[position]);
|
|
18975
18973
|
}
|
|
18974
|
+
function assertRangeValid(range) {
|
|
18975
|
+
if (!isZoneValid(range.zone)) {
|
|
18976
|
+
throw new Error(_lt("Invalid reference"));
|
|
18977
|
+
}
|
|
18978
|
+
if (range.invalidSheetName) {
|
|
18979
|
+
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18980
|
+
}
|
|
18981
|
+
}
|
|
18976
18982
|
return [refFn, range, evalContext];
|
|
18977
18983
|
}
|
|
18978
18984
|
/**
|
|
@@ -19285,25 +19291,26 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19285
19291
|
*/
|
|
19286
19292
|
this.rulePredicate = {
|
|
19287
19293
|
CellIsRule: (cell, rule) => {
|
|
19294
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19288
19295
|
if (cell && cell.evaluated.type === CellValueType.error) {
|
|
19289
19296
|
return false;
|
|
19290
19297
|
}
|
|
19291
19298
|
const values = rule.values.map(parsePrimitiveContent);
|
|
19292
19299
|
switch (rule.operator) {
|
|
19293
19300
|
case "IsEmpty":
|
|
19294
|
-
return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
|
|
19301
|
+
return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
|
|
19295
19302
|
case "IsNotEmpty":
|
|
19296
|
-
return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
|
|
19303
|
+
return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
|
|
19297
19304
|
case "BeginsWith":
|
|
19298
19305
|
if (!cell && values[0] === "") {
|
|
19299
19306
|
return false;
|
|
19300
19307
|
}
|
|
19301
|
-
return (isDefined(cell) && (cell === null ||
|
|
19308
|
+
return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
|
|
19302
19309
|
case "EndsWith":
|
|
19303
19310
|
if (!cell && values[0] === "") {
|
|
19304
19311
|
return false;
|
|
19305
19312
|
}
|
|
19306
|
-
return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
|
|
19313
|
+
return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
|
|
19307
19314
|
case "Between":
|
|
19308
19315
|
return (isDefined(cell) &&
|
|
19309
19316
|
cell.evaluated.value >= values[0] &&
|
|
@@ -19313,11 +19320,11 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19313
19320
|
cell.evaluated.value >= values[0] &&
|
|
19314
19321
|
cell.evaluated.value <= values[1]);
|
|
19315
19322
|
case "ContainsText":
|
|
19316
|
-
return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
|
|
19323
|
+
return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
|
|
19317
19324
|
case "NotContains":
|
|
19318
19325
|
return (!isDefined(cell) ||
|
|
19319
19326
|
!cell.evaluated.value ||
|
|
19320
|
-
cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
|
|
19327
|
+
((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
|
|
19321
19328
|
case "GreaterThan":
|
|
19322
19329
|
return isDefined(cell) && cell.evaluated.value > values[0];
|
|
19323
19330
|
case "GreaterThanOrEqual":
|
|
@@ -19426,39 +19433,34 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19426
19433
|
this.computedIcons[activeSheetId] = {};
|
|
19427
19434
|
const computedStyle = this.computedStyles[activeSheetId];
|
|
19428
19435
|
for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
for (let
|
|
19445
|
-
|
|
19446
|
-
|
|
19447
|
-
|
|
19448
|
-
if (
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19453
|
-
}
|
|
19436
|
+
switch (cf.rule.type) {
|
|
19437
|
+
case "ColorScaleRule":
|
|
19438
|
+
for (let range of cf.ranges) {
|
|
19439
|
+
this.applyColorScale(range, cf.rule);
|
|
19440
|
+
}
|
|
19441
|
+
break;
|
|
19442
|
+
case "IconSetRule":
|
|
19443
|
+
for (let range of cf.ranges) {
|
|
19444
|
+
this.applyIcon(range, cf.rule);
|
|
19445
|
+
}
|
|
19446
|
+
break;
|
|
19447
|
+
default:
|
|
19448
|
+
for (let ref of cf.ranges) {
|
|
19449
|
+
const zone = toZone(ref);
|
|
19450
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
19451
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
19452
|
+
const pr = this.rulePredicate[cf.rule.type];
|
|
19453
|
+
let cell = this.getters.getCell(activeSheetId, col, row);
|
|
19454
|
+
if (pr && pr(cell, cf.rule)) {
|
|
19455
|
+
if (!computedStyle[col])
|
|
19456
|
+
computedStyle[col] = [];
|
|
19457
|
+
// we must combine all the properties of all the CF rules applied to the given cell
|
|
19458
|
+
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19454
19459
|
}
|
|
19455
19460
|
}
|
|
19456
19461
|
}
|
|
19457
|
-
|
|
19458
|
-
|
|
19459
|
-
}
|
|
19460
|
-
catch (_) {
|
|
19461
|
-
// we don't care about the errors within the evaluation of a rule
|
|
19462
|
+
}
|
|
19463
|
+
break;
|
|
19462
19464
|
}
|
|
19463
19465
|
}
|
|
19464
19466
|
}
|
|
@@ -19477,7 +19479,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19477
19479
|
return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
|
|
19478
19480
|
case "formula":
|
|
19479
19481
|
const value = threshold.value && this.getters.evaluateFormula(threshold.value);
|
|
19480
|
-
return
|
|
19482
|
+
return typeof value === "number" ? value : null;
|
|
19481
19483
|
default:
|
|
19482
19484
|
return null;
|
|
19483
19485
|
}
|
|
@@ -31440,6 +31442,6 @@ exports.registries = registries;
|
|
|
31440
31442
|
exports.setTranslationMethod = setTranslationMethod;
|
|
31441
31443
|
|
|
31442
31444
|
|
|
31443
|
-
__info__.version = '15.2.
|
|
31444
|
-
__info__.date = '2024-01-
|
|
31445
|
-
__info__.hash = '
|
|
31445
|
+
__info__.version = '15.2.16';
|
|
31446
|
+
__info__.date = '2024-01-29T13:48:09.354Z';
|
|
31447
|
+
__info__.hash = '446a537';
|
|
@@ -18763,13 +18763,18 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18763
18763
|
// Getters
|
|
18764
18764
|
// ---------------------------------------------------------------------------
|
|
18765
18765
|
evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
|
|
18766
|
-
|
|
18767
|
-
|
|
18768
|
-
|
|
18769
|
-
|
|
18770
|
-
|
|
18766
|
+
try {
|
|
18767
|
+
const compiledFormula = compile(formulaString);
|
|
18768
|
+
const params = this.getFormulaParameters(() => { });
|
|
18769
|
+
const ranges = [];
|
|
18770
|
+
for (let xc of compiledFormula.dependencies) {
|
|
18771
|
+
ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
|
|
18772
|
+
}
|
|
18773
|
+
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18774
|
+
}
|
|
18775
|
+
catch {
|
|
18776
|
+
return "#ERROR";
|
|
18771
18777
|
}
|
|
18772
|
-
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18773
18778
|
}
|
|
18774
18779
|
/**
|
|
18775
18780
|
* Return the value of each cell in the range as they are displayed in the grid.
|
|
@@ -18881,10 +18886,8 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18881
18886
|
* that are actually present in the grid.
|
|
18882
18887
|
*/
|
|
18883
18888
|
function _range(range) {
|
|
18889
|
+
assertRangeValid(range);
|
|
18884
18890
|
const sheetId = range.sheetId;
|
|
18885
|
-
if (!isZoneValid(range.zone)) {
|
|
18886
|
-
throw new Error(_lt("Invalid reference"));
|
|
18887
|
-
}
|
|
18888
18891
|
// Performance issue: Avoid fetching data on positions that are out of the spreadsheet
|
|
18889
18892
|
// e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
|
|
18890
18893
|
const sheetZone = {
|
|
@@ -18923,21 +18926,16 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18923
18926
|
*/
|
|
18924
18927
|
function refFn(position, references, sheetId, isMeta, functionName, paramNumber) {
|
|
18925
18928
|
const range = references[position];
|
|
18929
|
+
assertRangeValid(range);
|
|
18926
18930
|
if (isMeta) {
|
|
18927
18931
|
return evalContext.getters.getRangeString(range, sheetId);
|
|
18928
18932
|
}
|
|
18929
|
-
if (!isZoneValid(range.zone)) {
|
|
18930
|
-
throw new Error(_lt("Invalid reference"));
|
|
18931
|
-
}
|
|
18932
18933
|
// if the formula definition could have accepted a range, we would pass through the _range function and not here
|
|
18933
18934
|
if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
|
|
18934
18935
|
throw new Error(paramNumber
|
|
18935
18936
|
? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
|
|
18936
18937
|
: _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
|
|
18937
18938
|
}
|
|
18938
|
-
if (range.invalidSheetName) {
|
|
18939
|
-
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18940
|
-
}
|
|
18941
18939
|
return readCell(range);
|
|
18942
18940
|
}
|
|
18943
18941
|
/**
|
|
@@ -18950,6 +18948,14 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
18950
18948
|
function range(position, references, sheetId) {
|
|
18951
18949
|
return _range(references[position]);
|
|
18952
18950
|
}
|
|
18951
|
+
function assertRangeValid(range) {
|
|
18952
|
+
if (!isZoneValid(range.zone)) {
|
|
18953
|
+
throw new Error(_lt("Invalid reference"));
|
|
18954
|
+
}
|
|
18955
|
+
if (range.invalidSheetName) {
|
|
18956
|
+
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18957
|
+
}
|
|
18958
|
+
}
|
|
18953
18959
|
return [refFn, range, evalContext];
|
|
18954
18960
|
}
|
|
18955
18961
|
/**
|
|
@@ -19262,25 +19268,26 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19262
19268
|
*/
|
|
19263
19269
|
this.rulePredicate = {
|
|
19264
19270
|
CellIsRule: (cell, rule) => {
|
|
19271
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19265
19272
|
if (cell && cell.evaluated.type === CellValueType.error) {
|
|
19266
19273
|
return false;
|
|
19267
19274
|
}
|
|
19268
19275
|
const values = rule.values.map(parsePrimitiveContent);
|
|
19269
19276
|
switch (rule.operator) {
|
|
19270
19277
|
case "IsEmpty":
|
|
19271
|
-
return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
|
|
19278
|
+
return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
|
|
19272
19279
|
case "IsNotEmpty":
|
|
19273
|
-
return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
|
|
19280
|
+
return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
|
|
19274
19281
|
case "BeginsWith":
|
|
19275
19282
|
if (!cell && values[0] === "") {
|
|
19276
19283
|
return false;
|
|
19277
19284
|
}
|
|
19278
|
-
return (isDefined(cell) && (cell === null ||
|
|
19285
|
+
return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
|
|
19279
19286
|
case "EndsWith":
|
|
19280
19287
|
if (!cell && values[0] === "") {
|
|
19281
19288
|
return false;
|
|
19282
19289
|
}
|
|
19283
|
-
return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
|
|
19290
|
+
return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
|
|
19284
19291
|
case "Between":
|
|
19285
19292
|
return (isDefined(cell) &&
|
|
19286
19293
|
cell.evaluated.value >= values[0] &&
|
|
@@ -19290,11 +19297,11 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19290
19297
|
cell.evaluated.value >= values[0] &&
|
|
19291
19298
|
cell.evaluated.value <= values[1]);
|
|
19292
19299
|
case "ContainsText":
|
|
19293
|
-
return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
|
|
19300
|
+
return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
|
|
19294
19301
|
case "NotContains":
|
|
19295
19302
|
return (!isDefined(cell) ||
|
|
19296
19303
|
!cell.evaluated.value ||
|
|
19297
|
-
cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
|
|
19304
|
+
((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
|
|
19298
19305
|
case "GreaterThan":
|
|
19299
19306
|
return isDefined(cell) && cell.evaluated.value > values[0];
|
|
19300
19307
|
case "GreaterThanOrEqual":
|
|
@@ -19403,39 +19410,34 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19403
19410
|
this.computedIcons[activeSheetId] = {};
|
|
19404
19411
|
const computedStyle = this.computedStyles[activeSheetId];
|
|
19405
19412
|
for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
|
|
19406
|
-
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
|
|
19412
|
-
|
|
19413
|
-
|
|
19414
|
-
|
|
19415
|
-
|
|
19416
|
-
|
|
19417
|
-
|
|
19418
|
-
|
|
19419
|
-
|
|
19420
|
-
|
|
19421
|
-
for (let
|
|
19422
|
-
|
|
19423
|
-
|
|
19424
|
-
|
|
19425
|
-
if (
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19430
|
-
}
|
|
19413
|
+
switch (cf.rule.type) {
|
|
19414
|
+
case "ColorScaleRule":
|
|
19415
|
+
for (let range of cf.ranges) {
|
|
19416
|
+
this.applyColorScale(range, cf.rule);
|
|
19417
|
+
}
|
|
19418
|
+
break;
|
|
19419
|
+
case "IconSetRule":
|
|
19420
|
+
for (let range of cf.ranges) {
|
|
19421
|
+
this.applyIcon(range, cf.rule);
|
|
19422
|
+
}
|
|
19423
|
+
break;
|
|
19424
|
+
default:
|
|
19425
|
+
for (let ref of cf.ranges) {
|
|
19426
|
+
const zone = toZone(ref);
|
|
19427
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
19428
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
19429
|
+
const pr = this.rulePredicate[cf.rule.type];
|
|
19430
|
+
let cell = this.getters.getCell(activeSheetId, col, row);
|
|
19431
|
+
if (pr && pr(cell, cf.rule)) {
|
|
19432
|
+
if (!computedStyle[col])
|
|
19433
|
+
computedStyle[col] = [];
|
|
19434
|
+
// we must combine all the properties of all the CF rules applied to the given cell
|
|
19435
|
+
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19431
19436
|
}
|
|
19432
19437
|
}
|
|
19433
19438
|
}
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
}
|
|
19437
|
-
catch (_) {
|
|
19438
|
-
// we don't care about the errors within the evaluation of a rule
|
|
19439
|
+
}
|
|
19440
|
+
break;
|
|
19439
19441
|
}
|
|
19440
19442
|
}
|
|
19441
19443
|
}
|
|
@@ -19454,7 +19456,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
|
|
|
19454
19456
|
return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
|
|
19455
19457
|
case "formula":
|
|
19456
19458
|
const value = threshold.value && this.getters.evaluateFormula(threshold.value);
|
|
19457
|
-
return
|
|
19459
|
+
return typeof value === "number" ? value : null;
|
|
19458
19460
|
default:
|
|
19459
19461
|
return null;
|
|
19460
19462
|
}
|
|
@@ -31394,6 +31396,6 @@ const helpers = {
|
|
|
31394
31396
|
export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
|
|
31395
31397
|
|
|
31396
31398
|
|
|
31397
|
-
__info__.version = '15.2.
|
|
31398
|
-
__info__.date = '2024-01-
|
|
31399
|
-
__info__.hash = '
|
|
31399
|
+
__info__.version = '15.2.16';
|
|
31400
|
+
__info__.date = '2024-01-29T13:48:09.354Z';
|
|
31401
|
+
__info__.hash = '446a537';
|
|
@@ -18783,13 +18783,18 @@
|
|
|
18783
18783
|
// Getters
|
|
18784
18784
|
// ---------------------------------------------------------------------------
|
|
18785
18785
|
evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
18789
|
-
|
|
18790
|
-
|
|
18786
|
+
try {
|
|
18787
|
+
const compiledFormula = compile(formulaString);
|
|
18788
|
+
const params = this.getFormulaParameters(() => { });
|
|
18789
|
+
const ranges = [];
|
|
18790
|
+
for (let xc of compiledFormula.dependencies) {
|
|
18791
|
+
ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
|
|
18792
|
+
}
|
|
18793
|
+
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18794
|
+
}
|
|
18795
|
+
catch {
|
|
18796
|
+
return "#ERROR";
|
|
18791
18797
|
}
|
|
18792
|
-
return compiledFormula.execute(ranges, sheetId, ...params);
|
|
18793
18798
|
}
|
|
18794
18799
|
/**
|
|
18795
18800
|
* Return the value of each cell in the range as they are displayed in the grid.
|
|
@@ -18901,10 +18906,8 @@
|
|
|
18901
18906
|
* that are actually present in the grid.
|
|
18902
18907
|
*/
|
|
18903
18908
|
function _range(range) {
|
|
18909
|
+
assertRangeValid(range);
|
|
18904
18910
|
const sheetId = range.sheetId;
|
|
18905
|
-
if (!isZoneValid(range.zone)) {
|
|
18906
|
-
throw new Error(_lt("Invalid reference"));
|
|
18907
|
-
}
|
|
18908
18911
|
// Performance issue: Avoid fetching data on positions that are out of the spreadsheet
|
|
18909
18912
|
// e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
|
|
18910
18913
|
const sheetZone = {
|
|
@@ -18943,21 +18946,16 @@
|
|
|
18943
18946
|
*/
|
|
18944
18947
|
function refFn(position, references, sheetId, isMeta, functionName, paramNumber) {
|
|
18945
18948
|
const range = references[position];
|
|
18949
|
+
assertRangeValid(range);
|
|
18946
18950
|
if (isMeta) {
|
|
18947
18951
|
return evalContext.getters.getRangeString(range, sheetId);
|
|
18948
18952
|
}
|
|
18949
|
-
if (!isZoneValid(range.zone)) {
|
|
18950
|
-
throw new Error(_lt("Invalid reference"));
|
|
18951
|
-
}
|
|
18952
18953
|
// if the formula definition could have accepted a range, we would pass through the _range function and not here
|
|
18953
18954
|
if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
|
|
18954
18955
|
throw new Error(paramNumber
|
|
18955
18956
|
? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
|
|
18956
18957
|
: _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
|
|
18957
18958
|
}
|
|
18958
|
-
if (range.invalidSheetName) {
|
|
18959
|
-
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18960
|
-
}
|
|
18961
18959
|
return readCell(range);
|
|
18962
18960
|
}
|
|
18963
18961
|
/**
|
|
@@ -18970,6 +18968,14 @@
|
|
|
18970
18968
|
function range(position, references, sheetId) {
|
|
18971
18969
|
return _range(references[position]);
|
|
18972
18970
|
}
|
|
18971
|
+
function assertRangeValid(range) {
|
|
18972
|
+
if (!isZoneValid(range.zone)) {
|
|
18973
|
+
throw new Error(_lt("Invalid reference"));
|
|
18974
|
+
}
|
|
18975
|
+
if (range.invalidSheetName) {
|
|
18976
|
+
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18977
|
+
}
|
|
18978
|
+
}
|
|
18973
18979
|
return [refFn, range, evalContext];
|
|
18974
18980
|
}
|
|
18975
18981
|
/**
|
|
@@ -19282,25 +19288,26 @@
|
|
|
19282
19288
|
*/
|
|
19283
19289
|
this.rulePredicate = {
|
|
19284
19290
|
CellIsRule: (cell, rule) => {
|
|
19291
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19285
19292
|
if (cell && cell.evaluated.type === CellValueType.error) {
|
|
19286
19293
|
return false;
|
|
19287
19294
|
}
|
|
19288
19295
|
const values = rule.values.map(parsePrimitiveContent);
|
|
19289
19296
|
switch (rule.operator) {
|
|
19290
19297
|
case "IsEmpty":
|
|
19291
|
-
return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
|
|
19298
|
+
return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
|
|
19292
19299
|
case "IsNotEmpty":
|
|
19293
|
-
return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
|
|
19300
|
+
return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
|
|
19294
19301
|
case "BeginsWith":
|
|
19295
19302
|
if (!cell && values[0] === "") {
|
|
19296
19303
|
return false;
|
|
19297
19304
|
}
|
|
19298
|
-
return (isDefined(cell) && (cell === null ||
|
|
19305
|
+
return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
|
|
19299
19306
|
case "EndsWith":
|
|
19300
19307
|
if (!cell && values[0] === "") {
|
|
19301
19308
|
return false;
|
|
19302
19309
|
}
|
|
19303
|
-
return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
|
|
19310
|
+
return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
|
|
19304
19311
|
case "Between":
|
|
19305
19312
|
return (isDefined(cell) &&
|
|
19306
19313
|
cell.evaluated.value >= values[0] &&
|
|
@@ -19310,11 +19317,11 @@
|
|
|
19310
19317
|
cell.evaluated.value >= values[0] &&
|
|
19311
19318
|
cell.evaluated.value <= values[1]);
|
|
19312
19319
|
case "ContainsText":
|
|
19313
|
-
return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
|
|
19320
|
+
return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
|
|
19314
19321
|
case "NotContains":
|
|
19315
19322
|
return (!isDefined(cell) ||
|
|
19316
19323
|
!cell.evaluated.value ||
|
|
19317
|
-
cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
|
|
19324
|
+
((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
|
|
19318
19325
|
case "GreaterThan":
|
|
19319
19326
|
return isDefined(cell) && cell.evaluated.value > values[0];
|
|
19320
19327
|
case "GreaterThanOrEqual":
|
|
@@ -19423,39 +19430,34 @@
|
|
|
19423
19430
|
this.computedIcons[activeSheetId] = {};
|
|
19424
19431
|
const computedStyle = this.computedStyles[activeSheetId];
|
|
19425
19432
|
for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
for (let
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19445
|
-
if (
|
|
19446
|
-
|
|
19447
|
-
|
|
19448
|
-
|
|
19449
|
-
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19450
|
-
}
|
|
19433
|
+
switch (cf.rule.type) {
|
|
19434
|
+
case "ColorScaleRule":
|
|
19435
|
+
for (let range of cf.ranges) {
|
|
19436
|
+
this.applyColorScale(range, cf.rule);
|
|
19437
|
+
}
|
|
19438
|
+
break;
|
|
19439
|
+
case "IconSetRule":
|
|
19440
|
+
for (let range of cf.ranges) {
|
|
19441
|
+
this.applyIcon(range, cf.rule);
|
|
19442
|
+
}
|
|
19443
|
+
break;
|
|
19444
|
+
default:
|
|
19445
|
+
for (let ref of cf.ranges) {
|
|
19446
|
+
const zone = toZone(ref);
|
|
19447
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
19448
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
19449
|
+
const pr = this.rulePredicate[cf.rule.type];
|
|
19450
|
+
let cell = this.getters.getCell(activeSheetId, col, row);
|
|
19451
|
+
if (pr && pr(cell, cf.rule)) {
|
|
19452
|
+
if (!computedStyle[col])
|
|
19453
|
+
computedStyle[col] = [];
|
|
19454
|
+
// we must combine all the properties of all the CF rules applied to the given cell
|
|
19455
|
+
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19451
19456
|
}
|
|
19452
19457
|
}
|
|
19453
19458
|
}
|
|
19454
|
-
|
|
19455
|
-
|
|
19456
|
-
}
|
|
19457
|
-
catch (_) {
|
|
19458
|
-
// we don't care about the errors within the evaluation of a rule
|
|
19459
|
+
}
|
|
19460
|
+
break;
|
|
19459
19461
|
}
|
|
19460
19462
|
}
|
|
19461
19463
|
}
|
|
@@ -19474,7 +19476,7 @@
|
|
|
19474
19476
|
return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
|
|
19475
19477
|
case "formula":
|
|
19476
19478
|
const value = threshold.value && this.getters.evaluateFormula(threshold.value);
|
|
19477
|
-
return
|
|
19479
|
+
return typeof value === "number" ? value : null;
|
|
19478
19480
|
default:
|
|
19479
19481
|
return null;
|
|
19480
19482
|
}
|
|
@@ -31439,9 +31441,9 @@
|
|
|
31439
31441
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
31440
31442
|
|
|
31441
31443
|
|
|
31442
|
-
__info__.version = '15.2.
|
|
31443
|
-
__info__.date = '2024-01-
|
|
31444
|
-
__info__.hash = '
|
|
31444
|
+
__info__.version = '15.2.16';
|
|
31445
|
+
__info__.date = '2024-01-29T13:48:09.354Z';
|
|
31446
|
+
__info__.hash = '446a537';
|
|
31445
31447
|
|
|
31446
31448
|
|
|
31447
31449
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|