@odoo/o-spreadsheet 15.0.15 → 15.0.17
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 +62 -67
- package/dist/o-spreadsheet.esm.js +62 -67
- package/dist/o-spreadsheet.iife.js +62 -67
- package/dist/o-spreadsheet.iife.min.js +2 -2
- package/package.json +1 -1
|
@@ -18727,15 +18727,20 @@
|
|
|
18727
18727
|
// Getters
|
|
18728
18728
|
// ---------------------------------------------------------------------------
|
|
18729
18729
|
evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
|
|
18730
|
+
try {
|
|
18731
|
+
let formula = normalize(formulaString);
|
|
18732
|
+
const compiledFormula = compile(formula);
|
|
18733
|
+
const params = this.getFormulaParameters(() => { });
|
|
18734
|
+
const ranges = [];
|
|
18735
|
+
for (let xc of formula.dependencies.references) {
|
|
18736
|
+
ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
|
|
18737
|
+
}
|
|
18738
|
+
const dependencies = { ...formula.dependencies, references: ranges };
|
|
18739
|
+
return compiledFormula(dependencies, sheetId, ...params);
|
|
18740
|
+
}
|
|
18741
|
+
catch (error) {
|
|
18742
|
+
return "#ERROR";
|
|
18736
18743
|
}
|
|
18737
|
-
const dependencies = { ...formula.dependencies, references: ranges };
|
|
18738
|
-
return compiledFormula(dependencies, sheetId, ...params);
|
|
18739
18744
|
}
|
|
18740
18745
|
/**
|
|
18741
18746
|
* Return the value of each cell in the range as they are displayed in the grid.
|
|
@@ -18816,17 +18821,10 @@
|
|
|
18816
18821
|
const evalContext = Object.assign(Object.create(functionMap), this.evalContext, {
|
|
18817
18822
|
getters: this.getters,
|
|
18818
18823
|
});
|
|
18819
|
-
const sheets = this.getters.getEvaluationSheets();
|
|
18820
18824
|
function readCell(range) {
|
|
18821
18825
|
var _a;
|
|
18822
|
-
|
|
18823
|
-
const
|
|
18824
|
-
if (s) {
|
|
18825
|
-
cell = (_a = s.rows[range.zone.top]) === null || _a === void 0 ? void 0 : _a.cells[range.zone.left];
|
|
18826
|
-
}
|
|
18827
|
-
else {
|
|
18828
|
-
throw new Error(_lt("Invalid sheet name"));
|
|
18829
|
-
}
|
|
18826
|
+
const sheet = evalContext.getters.getSheet(range.sheetId);
|
|
18827
|
+
const cell = (_a = sheet.rows[range.zone.top]) === null || _a === void 0 ? void 0 : _a.cells[range.zone.left];
|
|
18830
18828
|
if (!cell || cell.isEmpty()) {
|
|
18831
18829
|
// magic "empty" value
|
|
18832
18830
|
// Returning null instead of undefined will ensure that we don't
|
|
@@ -18849,10 +18847,8 @@
|
|
|
18849
18847
|
* that are actually present in the grid.
|
|
18850
18848
|
*/
|
|
18851
18849
|
function _range(range) {
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
throw new Error(_lt("Invalid reference"));
|
|
18855
|
-
}
|
|
18850
|
+
assertRangeValid(range);
|
|
18851
|
+
const sheet = evalContext.getters.getSheet(range.sheetId);
|
|
18856
18852
|
// Performance issue: Avoid fetching data on positions that are out of the spreadsheet
|
|
18857
18853
|
// e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
|
|
18858
18854
|
const sheetZone = {
|
|
@@ -18891,21 +18887,16 @@
|
|
|
18891
18887
|
*/
|
|
18892
18888
|
function refFn(position, references, sheetId, isMeta, functionName, paramNumber) {
|
|
18893
18889
|
const range = references[position];
|
|
18890
|
+
assertRangeValid(range);
|
|
18894
18891
|
if (isMeta) {
|
|
18895
18892
|
return evalContext.getters.getRangeString(range, sheetId);
|
|
18896
18893
|
}
|
|
18897
|
-
if (!isZoneValid(range.zone)) {
|
|
18898
|
-
throw new Error(_lt("Invalid reference"));
|
|
18899
|
-
}
|
|
18900
18894
|
// if the formula definition could have accepted a range, we would pass through the _range function and not here
|
|
18901
18895
|
if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
|
|
18902
18896
|
throw new Error(paramNumber
|
|
18903
18897
|
? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
|
|
18904
18898
|
: _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
|
|
18905
18899
|
}
|
|
18906
|
-
if (range.invalidSheetName) {
|
|
18907
|
-
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18908
|
-
}
|
|
18909
18900
|
return readCell(range);
|
|
18910
18901
|
}
|
|
18911
18902
|
/**
|
|
@@ -18918,6 +18909,14 @@
|
|
|
18918
18909
|
function range(position, references, sheetId) {
|
|
18919
18910
|
return _range(references[position]);
|
|
18920
18911
|
}
|
|
18912
|
+
function assertRangeValid(range) {
|
|
18913
|
+
if (!isZoneValid(range.zone)) {
|
|
18914
|
+
throw new Error(_lt("Invalid reference"));
|
|
18915
|
+
}
|
|
18916
|
+
if (range.invalidSheetName) {
|
|
18917
|
+
throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
|
|
18918
|
+
}
|
|
18919
|
+
}
|
|
18921
18920
|
return [refFn, range, evalContext];
|
|
18922
18921
|
}
|
|
18923
18922
|
/**
|
|
@@ -19230,25 +19229,26 @@
|
|
|
19230
19229
|
*/
|
|
19231
19230
|
this.rulePredicate = {
|
|
19232
19231
|
CellIsRule: (cell, rule) => {
|
|
19232
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19233
19233
|
if (cell && cell.evaluated.type === CellValueType.error) {
|
|
19234
19234
|
return false;
|
|
19235
19235
|
}
|
|
19236
19236
|
const values = rule.values.map(parsePrimitiveContent);
|
|
19237
19237
|
switch (rule.operator) {
|
|
19238
19238
|
case "IsEmpty":
|
|
19239
|
-
return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
|
|
19239
|
+
return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
|
|
19240
19240
|
case "IsNotEmpty":
|
|
19241
|
-
return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
|
|
19241
|
+
return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
|
|
19242
19242
|
case "BeginsWith":
|
|
19243
19243
|
if (!cell && values[0] === "") {
|
|
19244
19244
|
return false;
|
|
19245
19245
|
}
|
|
19246
|
-
return (isDefined(cell) && (cell === null ||
|
|
19246
|
+
return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
|
|
19247
19247
|
case "EndsWith":
|
|
19248
19248
|
if (!cell && values[0] === "") {
|
|
19249
19249
|
return false;
|
|
19250
19250
|
}
|
|
19251
|
-
return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
|
|
19251
|
+
return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
|
|
19252
19252
|
case "Between":
|
|
19253
19253
|
return (isDefined(cell) &&
|
|
19254
19254
|
cell.evaluated.value >= values[0] &&
|
|
@@ -19258,11 +19258,11 @@
|
|
|
19258
19258
|
cell.evaluated.value >= values[0] &&
|
|
19259
19259
|
cell.evaluated.value <= values[1]);
|
|
19260
19260
|
case "ContainsText":
|
|
19261
|
-
return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
|
|
19261
|
+
return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
|
|
19262
19262
|
case "NotContains":
|
|
19263
19263
|
return (!isDefined(cell) ||
|
|
19264
19264
|
!cell.evaluated.value ||
|
|
19265
|
-
cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
|
|
19265
|
+
((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
|
|
19266
19266
|
case "GreaterThan":
|
|
19267
19267
|
return isDefined(cell) && cell.evaluated.value > values[0];
|
|
19268
19268
|
case "GreaterThanOrEqual":
|
|
@@ -19371,39 +19371,34 @@
|
|
|
19371
19371
|
this.computedIcons[activeSheetId] = {};
|
|
19372
19372
|
const computedStyle = this.computedStyles[activeSheetId];
|
|
19373
19373
|
for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
for (let
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
if (
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19398
|
-
}
|
|
19374
|
+
switch (cf.rule.type) {
|
|
19375
|
+
case "ColorScaleRule":
|
|
19376
|
+
for (let range of cf.ranges) {
|
|
19377
|
+
this.applyColorScale(range, cf.rule);
|
|
19378
|
+
}
|
|
19379
|
+
break;
|
|
19380
|
+
case "IconSetRule":
|
|
19381
|
+
for (let range of cf.ranges) {
|
|
19382
|
+
this.applyIcon(range, cf.rule);
|
|
19383
|
+
}
|
|
19384
|
+
break;
|
|
19385
|
+
default:
|
|
19386
|
+
for (let ref of cf.ranges) {
|
|
19387
|
+
const zone = toZone(ref);
|
|
19388
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
19389
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
19390
|
+
const pr = this.rulePredicate[cf.rule.type];
|
|
19391
|
+
let cell = this.getters.getCell(activeSheetId, col, row);
|
|
19392
|
+
if (pr && pr(cell, cf.rule)) {
|
|
19393
|
+
if (!computedStyle[col])
|
|
19394
|
+
computedStyle[col] = [];
|
|
19395
|
+
// we must combine all the properties of all the CF rules applied to the given cell
|
|
19396
|
+
computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
|
|
19399
19397
|
}
|
|
19400
19398
|
}
|
|
19401
19399
|
}
|
|
19402
|
-
|
|
19403
|
-
|
|
19404
|
-
}
|
|
19405
|
-
catch (_) {
|
|
19406
|
-
// we don't care about the errors within the evaluation of a rule
|
|
19400
|
+
}
|
|
19401
|
+
break;
|
|
19407
19402
|
}
|
|
19408
19403
|
}
|
|
19409
19404
|
}
|
|
@@ -19422,7 +19417,7 @@
|
|
|
19422
19417
|
return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
|
|
19423
19418
|
case "formula":
|
|
19424
19419
|
const value = threshold.value && this.getters.evaluateFormula(threshold.value);
|
|
19425
|
-
return
|
|
19420
|
+
return typeof value === "number" ? value : null;
|
|
19426
19421
|
default:
|
|
19427
19422
|
return null;
|
|
19428
19423
|
}
|
|
@@ -31506,9 +31501,9 @@
|
|
|
31506
31501
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
31507
31502
|
|
|
31508
31503
|
|
|
31509
|
-
__info__.version = '15.0.
|
|
31510
|
-
__info__.date = '2024-01-
|
|
31511
|
-
__info__.hash = '
|
|
31504
|
+
__info__.version = '15.0.17';
|
|
31505
|
+
__info__.date = '2024-01-29T13:46:44.293Z';
|
|
31506
|
+
__info__.hash = '6944f99';
|
|
31512
31507
|
|
|
31513
31508
|
|
|
31514
31509
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|