@odoo/o-spreadsheet 17.4.0-alpha.3 → 17.4.0-alpha.5
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 +704 -795
- package/dist/o-spreadsheet.d.ts +198 -120
- package/dist/o-spreadsheet.esm.js +704 -795
- package/dist/o-spreadsheet.iife.js +704 -795
- package/dist/o-spreadsheet.iife.min.js +370 -361
- package/dist/o_spreadsheet.xml +44 -33
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
5
5
|
* @see https://github.com/odoo/o-spreadsheet
|
|
6
|
-
* @version 17.4.0-alpha.
|
|
7
|
-
* @date 2024-06-
|
|
8
|
-
* @hash
|
|
6
|
+
* @version 17.4.0-alpha.5
|
|
7
|
+
* @date 2024-06-14T10:01:40.605Z
|
|
8
|
+
* @hash 9ceed96
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
(function (exports, owl) {
|
|
@@ -1827,22 +1827,28 @@
|
|
|
1827
1827
|
*/
|
|
1828
1828
|
const getFormulaNumberRegex = memoize(function getFormulaNumberRegex(decimalSeparator) {
|
|
1829
1829
|
decimalSeparator = escapeRegExp(decimalSeparator);
|
|
1830
|
-
return new RegExp(`(
|
|
1830
|
+
return new RegExp(`(?:^-?\\d+(?:${decimalSeparator}?\\d*(?:e\\d+)?)?|^-?${decimalSeparator}\\d+)(?!\\w|!)`);
|
|
1831
1831
|
});
|
|
1832
1832
|
const getNumberRegex = memoize(function getNumberRegex(locale) {
|
|
1833
1833
|
const decimalSeparator = escapeRegExp(locale.decimalSeparator);
|
|
1834
1834
|
const thousandsSeparator = escapeRegExp(locale.thousandsSeparator);
|
|
1835
|
-
const pIntegerAndDecimals = `(
|
|
1836
|
-
const pOnlyDecimals = `(
|
|
1837
|
-
const pScientificFormat = "(e(
|
|
1838
|
-
const pPercentFormat = "(
|
|
1839
|
-
const pNumber = "(
|
|
1840
|
-
|
|
1841
|
-
|
|
1835
|
+
const pIntegerAndDecimals = `(?:\\d+(?:${thousandsSeparator}\\d{3,})*(?:${decimalSeparator}\\d*)?)`; // pattern that match integer number with or without decimal digits
|
|
1836
|
+
const pOnlyDecimals = `(?:${decimalSeparator}\\d+)`; // pattern that match only expression with decimal digits
|
|
1837
|
+
const pScientificFormat = "(?:e(?:\\+|-)?\\d+)?"; // pattern that match scientific format between zero and one time (should be placed before pPercentFormat)
|
|
1838
|
+
const pPercentFormat = "(?:\\s*%)?"; // pattern that match percent symbol between zero and one time
|
|
1839
|
+
const pNumber = "(?:\\s*" +
|
|
1840
|
+
pIntegerAndDecimals +
|
|
1841
|
+
"|" +
|
|
1842
|
+
pOnlyDecimals +
|
|
1843
|
+
")" +
|
|
1844
|
+
pScientificFormat +
|
|
1845
|
+
pPercentFormat;
|
|
1846
|
+
const pMinus = "(?:\\s*-)?"; // pattern that match negative symbol between zero and one time
|
|
1847
|
+
const pCurrencyFormat = "(?:\\s*[\\$€])?";
|
|
1842
1848
|
const p1 = pMinus + pCurrencyFormat + pNumber;
|
|
1843
1849
|
const p2 = pMinus + pNumber + pCurrencyFormat;
|
|
1844
1850
|
const p3 = pCurrencyFormat + pMinus + pNumber;
|
|
1845
|
-
const pNumberExp = "^((" + [p1, p2, p3].join(")|(") + "))$";
|
|
1851
|
+
const pNumberExp = "^(?:(?:" + [p1, p2, p3].join(")|(?:") + "))$";
|
|
1846
1852
|
const numberRegexp = new RegExp(pNumberExp, "i");
|
|
1847
1853
|
return numberRegexp;
|
|
1848
1854
|
});
|
|
@@ -2780,7 +2786,7 @@
|
|
|
2780
2786
|
return false;
|
|
2781
2787
|
}
|
|
2782
2788
|
if (typeof operand === "number" && operator === "=") {
|
|
2783
|
-
return toString(
|
|
2789
|
+
return value.toString() === operand.toString();
|
|
2784
2790
|
}
|
|
2785
2791
|
if (operator === "<>" || operator === "=") {
|
|
2786
2792
|
let result;
|
|
@@ -2840,14 +2846,13 @@
|
|
|
2840
2846
|
if (countArg % 2 === 1) {
|
|
2841
2847
|
throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));
|
|
2842
2848
|
}
|
|
2843
|
-
const
|
|
2844
|
-
const
|
|
2849
|
+
const firstArg = toMatrix(args[0]);
|
|
2850
|
+
const dimRow = firstArg.length;
|
|
2851
|
+
const dimCol = firstArg[0].length;
|
|
2845
2852
|
let predicates = [];
|
|
2846
2853
|
for (let i = 0; i < countArg - 1; i += 2) {
|
|
2847
|
-
const criteriaRange = args[i];
|
|
2848
|
-
if (
|
|
2849
|
-
criteriaRange.length !== dimRow ||
|
|
2850
|
-
criteriaRange[0].length !== dimCol) {
|
|
2854
|
+
const criteriaRange = toMatrix(args[i]);
|
|
2855
|
+
if (criteriaRange.length !== dimRow || criteriaRange[0].length !== dimCol) {
|
|
2851
2856
|
throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));
|
|
2852
2857
|
}
|
|
2853
2858
|
const description = toString(args[i + 1]);
|
|
@@ -2861,7 +2866,7 @@
|
|
|
2861
2866
|
for (let j = 0; j < dimCol; j++) {
|
|
2862
2867
|
let validatedPredicates = true;
|
|
2863
2868
|
for (let k = 0; k < countArg - 1; k += 2) {
|
|
2864
|
-
const criteriaValue = args[k][i][j].value;
|
|
2869
|
+
const criteriaValue = toMatrix(args[k])[i][j].value;
|
|
2865
2870
|
const criterion = predicates[k / 2];
|
|
2866
2871
|
validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
|
|
2867
2872
|
if (!validatedPredicates) {
|
|
@@ -3526,10 +3531,8 @@
|
|
|
3526
3531
|
const internalDate = parseDateTime(content, locale);
|
|
3527
3532
|
return internalDate.format;
|
|
3528
3533
|
}
|
|
3534
|
+
/** use this function only if the content corresponds to a number (means that isNumber(content) return true */
|
|
3529
3535
|
function detectNumberFormat(content) {
|
|
3530
|
-
if (!isNumber(content, DEFAULT_LOCALE)) {
|
|
3531
|
-
return undefined;
|
|
3532
|
-
}
|
|
3533
3536
|
const digitBase = content.includes(".") ? "0.00" : "0";
|
|
3534
3537
|
const matchedCurrencies = content.match(/[\$€]/);
|
|
3535
3538
|
if (matchedCurrencies) {
|
|
@@ -4732,21 +4735,16 @@
|
|
|
4732
4735
|
* Check if two zones are contiguous, ie. that they share a border
|
|
4733
4736
|
*/
|
|
4734
4737
|
function areZoneContiguous(zone1, zone2) {
|
|
4735
|
-
const u = union(zone1, zone2);
|
|
4736
4738
|
if (zone1.right + 1 === zone2.left || zone1.left === zone2.right + 1) {
|
|
4737
|
-
return
|
|
4739
|
+
return ((zone1.top <= zone2.bottom && zone1.top >= zone2.top) ||
|
|
4740
|
+
(zone2.top <= zone1.bottom && zone2.top >= zone1.top));
|
|
4738
4741
|
}
|
|
4739
4742
|
if (zone1.bottom + 1 === zone2.top || zone1.top === zone2.bottom + 1) {
|
|
4740
|
-
return
|
|
4743
|
+
return ((zone1.left <= zone2.right && zone1.left >= zone2.left) ||
|
|
4744
|
+
(zone2.left <= zone1.right && zone2.left >= zone1.left));
|
|
4741
4745
|
}
|
|
4742
4746
|
return false;
|
|
4743
4747
|
}
|
|
4744
|
-
function getZoneHeight(zone) {
|
|
4745
|
-
return zone.bottom - zone.top + 1;
|
|
4746
|
-
}
|
|
4747
|
-
function getZoneWidth(zone) {
|
|
4748
|
-
return zone.right - zone.left + 1;
|
|
4749
|
-
}
|
|
4750
4748
|
/**
|
|
4751
4749
|
* Merge contiguous and overlapping zones that are in the array into bigger zones
|
|
4752
4750
|
*/
|
|
@@ -5285,7 +5283,7 @@
|
|
|
5285
5283
|
return text;
|
|
5286
5284
|
}
|
|
5287
5285
|
const ellipsis = "…";
|
|
5288
|
-
const ellipsisWidth = computeCachedTextWidth(ctx,
|
|
5286
|
+
const ellipsisWidth = computeCachedTextWidth(ctx, ellipsis);
|
|
5289
5287
|
if (width <= ellipsisWidth) {
|
|
5290
5288
|
return text;
|
|
5291
5289
|
}
|
|
@@ -5502,7 +5500,7 @@
|
|
|
5502
5500
|
}
|
|
5503
5501
|
}
|
|
5504
5502
|
|
|
5505
|
-
function getClipboardDataPositions(zones) {
|
|
5503
|
+
function getClipboardDataPositions(sheetId, zones) {
|
|
5506
5504
|
const lefts = new Set(zones.map((z) => z.left));
|
|
5507
5505
|
const rights = new Set(zones.map((z) => z.right));
|
|
5508
5506
|
const tops = new Set(zones.map((z) => z.top));
|
|
@@ -5516,7 +5514,7 @@
|
|
|
5516
5514
|
const cellsPosition = clippedZones.map((zone) => positions(zone)).flat();
|
|
5517
5515
|
const columnsIndexes = [...new Set(cellsPosition.map((p) => p.col))].sort((a, b) => a - b);
|
|
5518
5516
|
const rowsIndexes = [...new Set(cellsPosition.map((p) => p.row))].sort((a, b) => a - b);
|
|
5519
|
-
return { zones, clippedZones, columnsIndexes, rowsIndexes };
|
|
5517
|
+
return { sheetId, zones, clippedZones, columnsIndexes, rowsIndexes };
|
|
5520
5518
|
}
|
|
5521
5519
|
/**
|
|
5522
5520
|
* The clipped zone is copied as many times as it fits in the target.
|
|
@@ -5566,8 +5564,8 @@
|
|
|
5566
5564
|
isCutAllowed(data) {
|
|
5567
5565
|
return "Success" /* CommandResult.Success */;
|
|
5568
5566
|
}
|
|
5569
|
-
getPasteTarget(target, content, options) {
|
|
5570
|
-
return { zones: [] };
|
|
5567
|
+
getPasteTarget(sheetId, target, content, options) {
|
|
5568
|
+
return { zones: [], sheetId };
|
|
5571
5569
|
}
|
|
5572
5570
|
convertOSClipboardData(data) {
|
|
5573
5571
|
return;
|
|
@@ -5605,7 +5603,7 @@
|
|
|
5605
5603
|
|
|
5606
5604
|
class BorderClipboardHandler extends AbstractCellClipboardHandler {
|
|
5607
5605
|
copy(data) {
|
|
5608
|
-
const sheetId =
|
|
5606
|
+
const sheetId = data.sheetId;
|
|
5609
5607
|
if (data.zones.length === 0) {
|
|
5610
5608
|
return;
|
|
5611
5609
|
}
|
|
@@ -5625,7 +5623,7 @@
|
|
|
5625
5623
|
if (!content) {
|
|
5626
5624
|
return;
|
|
5627
5625
|
}
|
|
5628
|
-
const sheetId =
|
|
5626
|
+
const sheetId = target.sheetId;
|
|
5629
5627
|
if (options?.pasteOption === "asValue") {
|
|
5630
5628
|
return;
|
|
5631
5629
|
}
|
|
@@ -6155,7 +6153,7 @@
|
|
|
6155
6153
|
if (!("zones" in data) || !data.zones.length) {
|
|
6156
6154
|
return;
|
|
6157
6155
|
}
|
|
6158
|
-
const sheetId =
|
|
6156
|
+
const sheetId = data.sheetId;
|
|
6159
6157
|
const zones = data.zones;
|
|
6160
6158
|
if (!zones.length) {
|
|
6161
6159
|
return {
|
|
@@ -6184,6 +6182,7 @@
|
|
|
6184
6182
|
format: evaluatedCell.format,
|
|
6185
6183
|
content,
|
|
6186
6184
|
isFormula: false,
|
|
6185
|
+
parsedValue: evaluatedCell.value,
|
|
6187
6186
|
};
|
|
6188
6187
|
}
|
|
6189
6188
|
cellsInRow.push({
|
|
@@ -6198,7 +6197,7 @@
|
|
|
6198
6197
|
return {
|
|
6199
6198
|
cells: clippedCells,
|
|
6200
6199
|
zones: clippedZones,
|
|
6201
|
-
sheetId:
|
|
6200
|
+
sheetId: data.sheetId,
|
|
6202
6201
|
};
|
|
6203
6202
|
}
|
|
6204
6203
|
isPasteAllowed(sheetId, target, content, clipboardOptions) {
|
|
@@ -6226,7 +6225,7 @@
|
|
|
6226
6225
|
return;
|
|
6227
6226
|
}
|
|
6228
6227
|
const zones = target.zones;
|
|
6229
|
-
const sheetId =
|
|
6228
|
+
const sheetId = target.sheetId;
|
|
6230
6229
|
if (!options?.isCutOperation) {
|
|
6231
6230
|
this.pasteFromCopy(sheetId, zones, content.cells, options);
|
|
6232
6231
|
}
|
|
@@ -6234,11 +6233,12 @@
|
|
|
6234
6233
|
this.pasteFromCut(sheetId, zones, content, options);
|
|
6235
6234
|
}
|
|
6236
6235
|
}
|
|
6237
|
-
getPasteTarget(target, content, options) {
|
|
6236
|
+
getPasteTarget(sheetId, target, content, options) {
|
|
6238
6237
|
const width = content.cells[0].length;
|
|
6239
6238
|
const height = content.cells.length;
|
|
6240
6239
|
if (options?.isCutOperation) {
|
|
6241
6240
|
return {
|
|
6241
|
+
sheetId,
|
|
6242
6242
|
zones: [
|
|
6243
6243
|
{
|
|
6244
6244
|
left: target[0].left,
|
|
@@ -6250,11 +6250,9 @@
|
|
|
6250
6250
|
};
|
|
6251
6251
|
}
|
|
6252
6252
|
if (width === 1 && height === 1) {
|
|
6253
|
-
return { zones: [] };
|
|
6253
|
+
return { zones: [], sheetId };
|
|
6254
6254
|
}
|
|
6255
|
-
return {
|
|
6256
|
-
zones: getPasteZones(target, content.cells),
|
|
6257
|
-
};
|
|
6255
|
+
return { sheetId, zones: getPasteZones(target, content.cells) };
|
|
6258
6256
|
}
|
|
6259
6257
|
pasteFromCut(sheetId, target, content, options) {
|
|
6260
6258
|
this.clearClippedZones(content);
|
|
@@ -6377,7 +6375,7 @@
|
|
|
6377
6375
|
|
|
6378
6376
|
class ChartClipboardHandler extends AbstractFigureClipboardHandler {
|
|
6379
6377
|
copy(data) {
|
|
6380
|
-
const sheetId =
|
|
6378
|
+
const sheetId = data.sheetId;
|
|
6381
6379
|
const figure = this.getters.getFigure(sheetId, data.figureId);
|
|
6382
6380
|
if (!figure) {
|
|
6383
6381
|
throw new Error(`No figure for the given id: ${data.figureId}`);
|
|
@@ -6397,22 +6395,19 @@
|
|
|
6397
6395
|
copiedChart,
|
|
6398
6396
|
};
|
|
6399
6397
|
}
|
|
6400
|
-
getPasteTarget(target, content, options) {
|
|
6398
|
+
getPasteTarget(sheetId, target, content, options) {
|
|
6401
6399
|
if (!content?.copiedFigure || !content?.copiedChart) {
|
|
6402
|
-
return { zones: [] };
|
|
6400
|
+
return { zones: [], sheetId };
|
|
6403
6401
|
}
|
|
6404
6402
|
const newId = new UuidGenerator().uuidv4();
|
|
6405
|
-
return {
|
|
6406
|
-
zones: [],
|
|
6407
|
-
figureId: newId,
|
|
6408
|
-
};
|
|
6403
|
+
return { zones: [], figureId: newId, sheetId };
|
|
6409
6404
|
}
|
|
6410
6405
|
paste(target, clippedContent, options) {
|
|
6411
6406
|
if (!clippedContent?.copiedFigure || !clippedContent?.copiedChart || !target.figureId) {
|
|
6412
6407
|
return;
|
|
6413
6408
|
}
|
|
6414
6409
|
const { zones, figureId } = target;
|
|
6415
|
-
const sheetId =
|
|
6410
|
+
const sheetId = target.sheetId;
|
|
6416
6411
|
const numCols = this.getters.getNumberCols(sheetId);
|
|
6417
6412
|
const numRows = this.getters.getNumberRows(sheetId);
|
|
6418
6413
|
const targetX = this.getters.getColDimensions(sheetId, zones[0].left).start;
|
|
@@ -6458,7 +6453,7 @@
|
|
|
6458
6453
|
return;
|
|
6459
6454
|
}
|
|
6460
6455
|
const { rowsIndexes, columnsIndexes } = data;
|
|
6461
|
-
const sheetId =
|
|
6456
|
+
const sheetId = data.sheetId;
|
|
6462
6457
|
const cellPositions = rowsIndexes.map((row) => columnsIndexes.map((col) => ({ col, row, sheetId })));
|
|
6463
6458
|
return {
|
|
6464
6459
|
cellPositions,
|
|
@@ -6472,7 +6467,7 @@
|
|
|
6472
6467
|
return;
|
|
6473
6468
|
}
|
|
6474
6469
|
const zones = target.zones;
|
|
6475
|
-
const sheetId =
|
|
6470
|
+
const sheetId = target.sheetId;
|
|
6476
6471
|
if (!options?.isCutOperation) {
|
|
6477
6472
|
this.pasteFromCopy(sheetId, zones, clippedContent.cellPositions);
|
|
6478
6473
|
}
|
|
@@ -6553,7 +6548,7 @@
|
|
|
6553
6548
|
return;
|
|
6554
6549
|
}
|
|
6555
6550
|
const { rowsIndexes, columnsIndexes } = data;
|
|
6556
|
-
const sheetId =
|
|
6551
|
+
const sheetId = data.sheetId;
|
|
6557
6552
|
const cellPositions = rowsIndexes.map((row) => columnsIndexes.map((col) => ({ col, row, sheetId })));
|
|
6558
6553
|
return {
|
|
6559
6554
|
cellPositions,
|
|
@@ -6570,7 +6565,7 @@
|
|
|
6570
6565
|
return;
|
|
6571
6566
|
}
|
|
6572
6567
|
const zones = target.zones;
|
|
6573
|
-
const sheetId =
|
|
6568
|
+
const sheetId = target.sheetId;
|
|
6574
6569
|
if (!options?.isCutOperation) {
|
|
6575
6570
|
this.pasteFromCopy(sheetId, zones, clippedContent.cellPositions);
|
|
6576
6571
|
}
|
|
@@ -6649,7 +6644,7 @@
|
|
|
6649
6644
|
|
|
6650
6645
|
class ImageClipboardHandler extends AbstractFigureClipboardHandler {
|
|
6651
6646
|
copy(data) {
|
|
6652
|
-
const sheetId =
|
|
6647
|
+
const sheetId = data.sheetId;
|
|
6653
6648
|
const figure = this.getters.getFigure(sheetId, data.figureId);
|
|
6654
6649
|
if (!figure) {
|
|
6655
6650
|
throw new Error(`No figure for the given id: ${data.figureId}`);
|
|
@@ -6667,15 +6662,12 @@
|
|
|
6667
6662
|
sheetId,
|
|
6668
6663
|
};
|
|
6669
6664
|
}
|
|
6670
|
-
getPasteTarget(target, content, options) {
|
|
6665
|
+
getPasteTarget(sheetId, target, content, options) {
|
|
6671
6666
|
if (!content?.copiedFigure || !content?.copiedImage) {
|
|
6672
|
-
return { zones: [] };
|
|
6667
|
+
return { zones: [], sheetId };
|
|
6673
6668
|
}
|
|
6674
6669
|
const newId = new UuidGenerator().uuidv4();
|
|
6675
|
-
return {
|
|
6676
|
-
zones: [],
|
|
6677
|
-
figureId: newId,
|
|
6678
|
-
};
|
|
6670
|
+
return { sheetId, zones: [], figureId: newId };
|
|
6679
6671
|
}
|
|
6680
6672
|
paste(target, clippedContent, options) {
|
|
6681
6673
|
if (!clippedContent?.copiedFigure || !clippedContent?.copiedImage || !target.figureId) {
|
|
@@ -6746,8 +6738,7 @@
|
|
|
6746
6738
|
if (options?.isCutOperation || !("zones" in target) || !target.zones.length) {
|
|
6747
6739
|
return;
|
|
6748
6740
|
}
|
|
6749
|
-
|
|
6750
|
-
this.pasteFromCopy(sheetId, target.zones, content.cells, options);
|
|
6741
|
+
this.pasteFromCopy(target.sheetId, target.zones, content.cells, options);
|
|
6751
6742
|
}
|
|
6752
6743
|
pasteZone(sheetId, col, row, cells) {
|
|
6753
6744
|
for (const [r, rowCells] of cells.entries()) {
|
|
@@ -6807,7 +6798,7 @@
|
|
|
6807
6798
|
|
|
6808
6799
|
class TableClipboardHandler extends AbstractCellClipboardHandler {
|
|
6809
6800
|
copy(data) {
|
|
6810
|
-
const sheetId =
|
|
6801
|
+
const sheetId = data.sheetId;
|
|
6811
6802
|
const { rowsIndexes, columnsIndexes, zones } = data;
|
|
6812
6803
|
if (!zones || !rowsIndexes.length || !columnsIndexes.length) {
|
|
6813
6804
|
return { tableCells: [[]], sheetId };
|
|
@@ -6849,7 +6840,7 @@
|
|
|
6849
6840
|
}
|
|
6850
6841
|
return {
|
|
6851
6842
|
tableCells,
|
|
6852
|
-
sheetId:
|
|
6843
|
+
sheetId: data.sheetId,
|
|
6853
6844
|
};
|
|
6854
6845
|
}
|
|
6855
6846
|
/**
|
|
@@ -6871,7 +6862,7 @@
|
|
|
6871
6862
|
return;
|
|
6872
6863
|
}
|
|
6873
6864
|
const zones = target.zones;
|
|
6874
|
-
const sheetId =
|
|
6865
|
+
const sheetId = target.sheetId;
|
|
6875
6866
|
if (!options?.isCutOperation) {
|
|
6876
6867
|
this.pasteFromCopy(sheetId, zones, content.tableCells, options);
|
|
6877
6868
|
}
|
|
@@ -7633,10 +7624,8 @@
|
|
|
7633
7624
|
return undefined;
|
|
7634
7625
|
}
|
|
7635
7626
|
|
|
7636
|
-
function evaluateLiteral(
|
|
7637
|
-
const value = localeFormat.format === PLAIN_TEXT_FORMAT
|
|
7638
|
-
? content
|
|
7639
|
-
: parseLiteral(content, localeFormat.locale);
|
|
7627
|
+
function evaluateLiteral(literalCell, localeFormat) {
|
|
7628
|
+
const value = localeFormat.format === PLAIN_TEXT_FORMAT ? literalCell.content : literalCell.parsedValue;
|
|
7640
7629
|
const fPayload = { value, format: localeFormat.format };
|
|
7641
7630
|
return createEvaluatedCell(fPayload, localeFormat.locale);
|
|
7642
7631
|
}
|
|
@@ -7648,10 +7637,11 @@
|
|
|
7648
7637
|
return null;
|
|
7649
7638
|
}
|
|
7650
7639
|
if (isNumber(content, DEFAULT_LOCALE)) {
|
|
7651
|
-
return
|
|
7640
|
+
return parseNumber(content, DEFAULT_LOCALE);
|
|
7652
7641
|
}
|
|
7653
|
-
|
|
7654
|
-
|
|
7642
|
+
const internalDate = parseDateTime(content, locale);
|
|
7643
|
+
if (internalDate) {
|
|
7644
|
+
return internalDate.value;
|
|
7655
7645
|
}
|
|
7656
7646
|
if (isBoolean(content)) {
|
|
7657
7647
|
return content.toUpperCase() === "TRUE" ? true : false;
|
|
@@ -7663,9 +7653,14 @@
|
|
|
7663
7653
|
if (!link) {
|
|
7664
7654
|
return _createEvaluatedCell(fPayload, locale, cell);
|
|
7665
7655
|
}
|
|
7656
|
+
const value = parseLiteral(link.label, locale);
|
|
7657
|
+
const format = fPayload.format ||
|
|
7658
|
+
(typeof value === "number"
|
|
7659
|
+
? detectDateFormat(link.label, locale) || detectNumberFormat(link.label)
|
|
7660
|
+
: undefined);
|
|
7666
7661
|
const linkPayload = {
|
|
7667
|
-
value
|
|
7668
|
-
format
|
|
7662
|
+
value,
|
|
7663
|
+
format,
|
|
7669
7664
|
};
|
|
7670
7665
|
return {
|
|
7671
7666
|
..._createEvaluatedCell(linkPayload, locale, cell),
|
|
@@ -10428,6 +10423,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10428
10423
|
function drawScoreChart(structure, canvas) {
|
|
10429
10424
|
const ctx = canvas.getContext("2d");
|
|
10430
10425
|
canvas.width = structure.canvas.width;
|
|
10426
|
+
const availableWidth = canvas.width - DEFAULT_CHART_PADDING;
|
|
10431
10427
|
canvas.height = structure.canvas.height;
|
|
10432
10428
|
ctx.fillStyle = structure.canvas.backgroundColor;
|
|
10433
10429
|
ctx.fillRect(0, 0, structure.canvas.width, structure.canvas.height);
|
|
@@ -10436,7 +10432,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10436
10432
|
ctx.fillStyle = structure.title.style.color;
|
|
10437
10433
|
const baseline = ctx.textBaseline;
|
|
10438
10434
|
ctx.textBaseline = "middle";
|
|
10439
|
-
ctx.fillText(clipTextWithEllipsis(ctx, structure.title.text,
|
|
10435
|
+
ctx.fillText(clipTextWithEllipsis(ctx, structure.title.text, availableWidth - structure.title.position.x), structure.title.position.x, structure.title.position.y);
|
|
10440
10436
|
ctx.textBaseline = baseline;
|
|
10441
10437
|
}
|
|
10442
10438
|
if (structure.baseline) {
|
|
@@ -10526,13 +10522,16 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10526
10522
|
return {
|
|
10527
10523
|
title: {
|
|
10528
10524
|
...chart.title,
|
|
10525
|
+
// chart titles are extracted from .json files and they are translated at runtime here
|
|
10529
10526
|
text: _t(chart.title.text ?? ""),
|
|
10530
10527
|
},
|
|
10531
10528
|
keyValue: formattedKeyValue,
|
|
10532
10529
|
baselineDisplay,
|
|
10533
10530
|
baselineArrow: getBaselineArrowDirection(baselineCell, keyValueCell, chart.baselineMode),
|
|
10534
10531
|
baselineColor: getBaselineColor(baselineCell, chart.baselineMode, keyValueCell, chart.baselineColorUp, chart.baselineColorDown),
|
|
10535
|
-
baselineDescr: chart.baselineMode !== "progress" && chart.baselineDescr
|
|
10532
|
+
baselineDescr: chart.baselineMode !== "progress" && chart.baselineDescr
|
|
10533
|
+
? _t(chart.baselineDescr) // descriptions are extracted from .json files and they are translated at runtime here
|
|
10534
|
+
: "",
|
|
10536
10535
|
fontColor,
|
|
10537
10536
|
background,
|
|
10538
10537
|
baselineStyle: chart.baselineMode !== "percentage" && chart.baselineMode !== "progress" && baseline
|
|
@@ -10561,7 +10560,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10561
10560
|
/* Sizes of boxes containing the texts, in percentage of the Chart size */
|
|
10562
10561
|
const KEY_BOX_HEIGHT_RATIO = 0.8;
|
|
10563
10562
|
/* Padding at the border of the chart */
|
|
10564
|
-
const CHART_PADDING =
|
|
10563
|
+
const CHART_PADDING = 10;
|
|
10565
10564
|
const BOTTOM_PADDING_RATIO = 0.05;
|
|
10566
10565
|
/**
|
|
10567
10566
|
* Line height (in em)
|
|
@@ -10711,6 +10710,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10711
10710
|
position: {
|
|
10712
10711
|
x: (this.width - keyWidth) / 2,
|
|
10713
10712
|
y: this.height * (0.5 - BOTTOM_PADDING_RATIO * 2) +
|
|
10713
|
+
CHART_PADDING / 2 +
|
|
10714
10714
|
(titleHeight + keyHeight / (this.baseline || this.baselineDescr ? 2 : 1.2)) / 2,
|
|
10715
10715
|
},
|
|
10716
10716
|
};
|
|
@@ -10770,7 +10770,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10770
10770
|
const remainingWidth = maxLineWidth - baselineValueWidth;
|
|
10771
10771
|
let baselineDescrFontSize = getFontSizeMatchingWidth(remainingWidth, baselineValueFontSize, (fontSize) => computeTextWidth(this.context, this.baselineDescr, { fontSize }));
|
|
10772
10772
|
let isBaselineSplit = false;
|
|
10773
|
-
if (baselineDescrFontSize < baselineValueFontSize / 2.5
|
|
10773
|
+
if (baselineDescrFontSize < baselineValueFontSize / 2.5 &&
|
|
10774
|
+
this.baselineDescr.trim().includes(" ")) {
|
|
10774
10775
|
isBaselineSplit = true;
|
|
10775
10776
|
baselineDescrFontSize = Math.floor(baselineValueFontSize / 2.5);
|
|
10776
10777
|
for (const line of splitTextInTwoLines(this.baselineDescr)) {
|
|
@@ -10819,7 +10820,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10819
10820
|
/** Get the height of the chart minus all the vertical paddings */
|
|
10820
10821
|
getDrawableHeight() {
|
|
10821
10822
|
const verticalPadding = CHART_PADDING + this.height * BOTTOM_PADDING_RATIO;
|
|
10822
|
-
let availableHeight = this.height -
|
|
10823
|
+
let availableHeight = this.height - verticalPadding;
|
|
10823
10824
|
availableHeight -= this.title ? DEFAULT_CHART_FONT_SIZE * LINE_HEIGHT : 0;
|
|
10824
10825
|
return availableHeight;
|
|
10825
10826
|
}
|
|
@@ -10861,6 +10862,11 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10861
10862
|
get runtime() {
|
|
10862
10863
|
return this.env.model.getters.getChartRuntime(this.props.figure.id);
|
|
10863
10864
|
}
|
|
10865
|
+
get title() {
|
|
10866
|
+
const title = this.env.model.getters.getChartDefinition(this.props.figure.id).title.text ?? "";
|
|
10867
|
+
// chart titles are extracted from .json files and they are translated at runtime here
|
|
10868
|
+
return _t(title);
|
|
10869
|
+
}
|
|
10864
10870
|
setup() {
|
|
10865
10871
|
owl.useEffect(this.createChart.bind(this), () => {
|
|
10866
10872
|
const canvas = this.canvas.el;
|
|
@@ -10989,6 +10995,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10989
10995
|
if (types.some((t) => t.startsWith("RANGE"))) {
|
|
10990
10996
|
result.acceptMatrix = true;
|
|
10991
10997
|
}
|
|
10998
|
+
if (types.every((t) => t.startsWith("RANGE"))) {
|
|
10999
|
+
result.acceptMatrixOnly = true;
|
|
11000
|
+
}
|
|
10992
11001
|
return result;
|
|
10993
11002
|
}
|
|
10994
11003
|
/**
|
|
@@ -11243,7 +11252,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11243
11252
|
arg("rows (number)", _t("The number of rows in the constrained array.")),
|
|
11244
11253
|
arg("columns (number)", _t("The number of columns in the constrained array.")),
|
|
11245
11254
|
],
|
|
11246
|
-
returns: ["RANGE<ANY>"],
|
|
11247
11255
|
compute: function (array, rows, columns) {
|
|
11248
11256
|
const _array = toMatrix(array);
|
|
11249
11257
|
const _rowsArg = toInteger(rows?.value, this.locale);
|
|
@@ -11266,15 +11274,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11266
11274
|
arg("col_num (number, range<number>)", _t("The first column index of the columns to be returned.")),
|
|
11267
11275
|
arg("col_num2 (number, range<number>, repeating)", _t("The columns indexes of the columns to be returned.")),
|
|
11268
11276
|
],
|
|
11269
|
-
returns: ["RANGE<ANY>"],
|
|
11270
11277
|
compute: function (array, ...columns) {
|
|
11271
11278
|
const _array = toMatrix(array);
|
|
11272
11279
|
const _columns = flattenRowFirst(columns, (item) => toInteger(item?.value, this.locale));
|
|
11273
|
-
|
|
11280
|
+
const argOutOfRange = _columns.filter((col) => col === 0 || _array.length < Math.abs(col));
|
|
11281
|
+
assert(() => argOutOfRange.length === 0, _t("The columns arguments must be between -%s and %s (got %s), excluding 0.", _array.length.toString(), _array.length.toString(), argOutOfRange.join(",")));
|
|
11274
11282
|
const result = Array(_columns.length);
|
|
11275
11283
|
for (let col = 0; col < _columns.length; col++) {
|
|
11276
|
-
|
|
11277
|
-
|
|
11284
|
+
if (_columns[col] > 0) {
|
|
11285
|
+
result[col] = _array[_columns[col] - 1]; // -1 because columns arguments are 1-indexed
|
|
11286
|
+
}
|
|
11287
|
+
else {
|
|
11288
|
+
result[col] = _array[_array.length + _columns[col]];
|
|
11289
|
+
}
|
|
11278
11290
|
}
|
|
11279
11291
|
return result;
|
|
11280
11292
|
},
|
|
@@ -11290,13 +11302,18 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11290
11302
|
arg("row_num (number, range<number>)", _t("The first row index of the rows to be returned.")),
|
|
11291
11303
|
arg("row_num2 (number, range<number>, repeating)", _t("The rows indexes of the rows to be returned.")),
|
|
11292
11304
|
],
|
|
11293
|
-
returns: ["RANGE<ANY>"],
|
|
11294
11305
|
compute: function (array, ...rows) {
|
|
11295
11306
|
const _array = toMatrix(array);
|
|
11296
11307
|
const _rows = flattenRowFirst(rows, (item) => toInteger(item?.value, this.locale));
|
|
11297
11308
|
const _nbColumns = _array.length;
|
|
11298
|
-
|
|
11299
|
-
|
|
11309
|
+
const argOutOfRange = _rows.filter((row) => row === 0 || _array[0].length < Math.abs(row));
|
|
11310
|
+
assert(() => argOutOfRange.length === 0, _t("The rows arguments must be between -%s and %s (got %s), excluding 0.", _array[0].length.toString(), _array[0].length.toString(), argOutOfRange.join(",")));
|
|
11311
|
+
return generateMatrix(_nbColumns, _rows.length, (col, row) => {
|
|
11312
|
+
if (_rows[row] > 0) {
|
|
11313
|
+
return _array[col][_rows[row] - 1]; // -1 because columns arguments are 1-indexed
|
|
11314
|
+
}
|
|
11315
|
+
return _array[col][_array[col].length + _rows[row]];
|
|
11316
|
+
});
|
|
11300
11317
|
},
|
|
11301
11318
|
isExported: true,
|
|
11302
11319
|
};
|
|
@@ -11311,7 +11328,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11311
11328
|
arg("columns (number, optional)", _t("The number of columns in the expanded array. If missing, columns will not be expanded.")),
|
|
11312
11329
|
arg("pad_with (any, default=0)", _t("The value with which to pad.")), // @compatibility: on Excel, pad with #N/A
|
|
11313
11330
|
],
|
|
11314
|
-
returns: ["RANGE<ANY>"],
|
|
11315
11331
|
compute: function (arg, rows, columns, padWith = { value: 0 } // TODO : Replace with #N/A errors once it's supported
|
|
11316
11332
|
) {
|
|
11317
11333
|
const _array = toMatrix(arg);
|
|
@@ -11332,7 +11348,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11332
11348
|
arg("range (any, range<any>)", _t("The first range to flatten.")),
|
|
11333
11349
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to flatten.")),
|
|
11334
11350
|
],
|
|
11335
|
-
returns: ["RANGE<ANY>"],
|
|
11336
11351
|
compute: function (...ranges) {
|
|
11337
11352
|
return [flattenRowFirst(ranges, (val) => (val === undefined ? { value: "" } : val))];
|
|
11338
11353
|
},
|
|
@@ -11347,7 +11362,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11347
11362
|
arg("data (range<number>)", _t("The array of ranges containing the values to be counted.")),
|
|
11348
11363
|
arg("classes (number, range<number>)", _t("The range containing the set of classes.")),
|
|
11349
11364
|
],
|
|
11350
|
-
returns: ["RANGE<NUMBER>"],
|
|
11351
11365
|
compute: function (data, classes) {
|
|
11352
11366
|
const _data = flattenRowFirst([data], (data) => data.value).filter((val) => typeof val === "number");
|
|
11353
11367
|
const _classes = flattenRowFirst([classes], (data) => data.value).filter((val) => typeof val === "number");
|
|
@@ -11395,7 +11409,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11395
11409
|
arg("range1 (any, range<any>)", _t("The first range to be appended.")),
|
|
11396
11410
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
|
|
11397
11411
|
],
|
|
11398
|
-
returns: ["RANGE<ANY>"],
|
|
11399
11412
|
compute: function (...ranges) {
|
|
11400
11413
|
const nbRows = Math.max(...ranges.map((r) => r?.[0]?.length ?? 0));
|
|
11401
11414
|
const result = [];
|
|
@@ -11422,7 +11435,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11422
11435
|
args: [
|
|
11423
11436
|
arg("square_matrix (number, range<number>)", _t("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.")),
|
|
11424
11437
|
],
|
|
11425
|
-
returns: ["NUMBER"],
|
|
11426
11438
|
compute: function (matrix) {
|
|
11427
11439
|
const _matrix = toNumberMatrix(matrix, "square_matrix");
|
|
11428
11440
|
assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
|
|
@@ -11438,7 +11450,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11438
11450
|
args: [
|
|
11439
11451
|
arg("square_matrix (number, range<number>)", _t("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.")),
|
|
11440
11452
|
],
|
|
11441
|
-
returns: ["RANGE<NUMBER>"],
|
|
11442
11453
|
compute: function (matrix) {
|
|
11443
11454
|
const _matrix = toNumberMatrix(matrix, "square_matrix");
|
|
11444
11455
|
assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
|
|
@@ -11459,7 +11470,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11459
11470
|
arg("matrix1 (number, range<number>)", _t("The first matrix in the matrix multiplication operation.")),
|
|
11460
11471
|
arg("matrix2 (number, range<number>)", _t("The second matrix in the matrix multiplication operation.")),
|
|
11461
11472
|
],
|
|
11462
|
-
returns: ["RANGE<NUMBER>"],
|
|
11463
11473
|
compute: function (matrix1, matrix2) {
|
|
11464
11474
|
const _matrix1 = toNumberMatrix(matrix1, "matrix1");
|
|
11465
11475
|
const _matrix2 = toNumberMatrix(matrix2, "matrix2");
|
|
@@ -11478,7 +11488,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11478
11488
|
arg("range1 (number, range<number>)", _t("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),
|
|
11479
11489
|
arg("range2 (number, range<number>, repeating)", _t("The other range whose entries will be multiplied with corresponding entries in the other ranges.")),
|
|
11480
11490
|
],
|
|
11481
|
-
returns: ["NUMBER"],
|
|
11482
11491
|
compute: function (...args) {
|
|
11483
11492
|
assertSameDimensions(_t("All the ranges must have the same dimensions."), ...args);
|
|
11484
11493
|
const _args = args.map(toMatrix);
|
|
@@ -11535,7 +11544,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11535
11544
|
arg("array_x (number, range<number>)", _t("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),
|
|
11536
11545
|
arg("array_y (number, range<number>)", _t("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.")),
|
|
11537
11546
|
],
|
|
11538
|
-
returns: ["NUMBER"],
|
|
11539
11547
|
compute: function (arrayX, arrayY) {
|
|
11540
11548
|
return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 - y ** 2);
|
|
11541
11549
|
},
|
|
@@ -11550,7 +11558,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11550
11558
|
arg("array_x (number, range<number>)", _t("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),
|
|
11551
11559
|
arg("array_y (number, range<number>)", _t("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.")),
|
|
11552
11560
|
],
|
|
11553
|
-
returns: ["NUMBER"],
|
|
11554
11561
|
compute: function (arrayX, arrayY) {
|
|
11555
11562
|
return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 + y ** 2);
|
|
11556
11563
|
},
|
|
@@ -11565,7 +11572,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11565
11572
|
arg("array_x (number, range<number>)", _t("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),
|
|
11566
11573
|
arg("array_y (number, range<number>)", _t("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.")),
|
|
11567
11574
|
],
|
|
11568
|
-
returns: ["NUMBER"],
|
|
11569
11575
|
compute: function (arrayX, arrayY) {
|
|
11570
11576
|
return getSumXAndY(arrayX, arrayY, (x, y) => (x - y) ** 2);
|
|
11571
11577
|
},
|
|
@@ -11601,7 +11607,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11601
11607
|
const TOCOL = {
|
|
11602
11608
|
description: _t("Transforms a range of cells into a single column."),
|
|
11603
11609
|
args: TO_COL_ROW_ARGS,
|
|
11604
|
-
returns: ["RANGE<ANY>"],
|
|
11605
11610
|
compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
|
|
11606
11611
|
const _array = toMatrix(array);
|
|
11607
11612
|
const _ignore = toNumber(ignore.value, this.locale);
|
|
@@ -11622,7 +11627,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11622
11627
|
const TOROW = {
|
|
11623
11628
|
description: _t("Transforms a range of cells into a single row."),
|
|
11624
11629
|
args: TO_COL_ROW_ARGS,
|
|
11625
|
-
returns: ["RANGE<ANY>"],
|
|
11626
11630
|
compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
|
|
11627
11631
|
const _array = toMatrix(array);
|
|
11628
11632
|
const _ignore = toNumber(ignore.value, this.locale);
|
|
@@ -11644,7 +11648,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11644
11648
|
const TRANSPOSE = {
|
|
11645
11649
|
description: _t("Transposes the rows and columns of a range."),
|
|
11646
11650
|
args: [arg("range (any, range<any>)", _t("The range to be transposed."))],
|
|
11647
|
-
returns: ["RANGE"],
|
|
11648
11651
|
compute: function (arg) {
|
|
11649
11652
|
const _array = toMatrix(arg);
|
|
11650
11653
|
const nbColumns = _array[0].length;
|
|
@@ -11662,7 +11665,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11662
11665
|
arg("range1 (any, range<any>)", _t("The first range to be appended.")),
|
|
11663
11666
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
|
|
11664
11667
|
],
|
|
11665
|
-
returns: ["RANGE<ANY>"],
|
|
11666
11668
|
compute: function (...ranges) {
|
|
11667
11669
|
const nbColumns = Math.max(...ranges.map((range) => toMatrix(range).length));
|
|
11668
11670
|
const nbRows = ranges.reduce((acc, range) => acc + toMatrix(range)[0].length, 0);
|
|
@@ -11694,7 +11696,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11694
11696
|
arg("pad_with (any, default=0)", // TODO : replace with #N/A
|
|
11695
11697
|
_t("The value with which to fill the extra cells in the range.")),
|
|
11696
11698
|
],
|
|
11697
|
-
returns: ["RANGE<ANY>"],
|
|
11698
11699
|
compute: function (range, wrapCount, padWith = { value: 0 }) {
|
|
11699
11700
|
const _array = toMatrix(range);
|
|
11700
11701
|
const nbRows = toInteger(wrapCount?.value, this.locale);
|
|
@@ -11719,7 +11720,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11719
11720
|
arg("pad_with (any, default=0)", // TODO : replace with #N/A
|
|
11720
11721
|
_t("The value with which to fill the extra cells in the range.")),
|
|
11721
11722
|
],
|
|
11722
|
-
returns: ["RANGE<ANY>"],
|
|
11723
11723
|
compute: function (range, wrapCount, padWith = { value: 0 }) {
|
|
11724
11724
|
const _array = toMatrix(range);
|
|
11725
11725
|
const nbColumns = toInteger(wrapCount?.value, this.locale);
|
|
@@ -11767,7 +11767,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11767
11767
|
arg("value (number)", _t("The number.")),
|
|
11768
11768
|
arg("unit (string, optional)", _t("The formatting unit. Use 'k', 'm', or 'b' to force the unit")),
|
|
11769
11769
|
],
|
|
11770
|
-
returns: ["NUMBER"],
|
|
11771
11770
|
compute: function (value, unite) {
|
|
11772
11771
|
return {
|
|
11773
11772
|
value: toNumber(value, this.locale),
|
|
@@ -11799,7 +11798,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11799
11798
|
const ABS = {
|
|
11800
11799
|
description: _t("Absolute value of a number."),
|
|
11801
11800
|
args: [arg("value (number)", _t("The number of which to return the absolute value."))],
|
|
11802
|
-
returns: ["NUMBER"],
|
|
11803
11801
|
compute: function (value) {
|
|
11804
11802
|
return Math.abs(toNumber(value, this.locale));
|
|
11805
11803
|
},
|
|
@@ -11813,7 +11811,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11813
11811
|
args: [
|
|
11814
11812
|
arg("value (number)", _t("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")),
|
|
11815
11813
|
],
|
|
11816
|
-
returns: ["NUMBER"],
|
|
11817
11814
|
compute: function (value) {
|
|
11818
11815
|
const _value = toNumber(value, this.locale);
|
|
11819
11816
|
assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11829,7 +11826,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11829
11826
|
args: [
|
|
11830
11827
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")),
|
|
11831
11828
|
],
|
|
11832
|
-
returns: ["NUMBER"],
|
|
11833
11829
|
compute: function (value) {
|
|
11834
11830
|
const _value = toNumber(value, this.locale);
|
|
11835
11831
|
assert(() => _value >= 1, _t("The value (%s) must be greater than or equal to 1.", _value.toString()));
|
|
@@ -11843,7 +11839,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11843
11839
|
const ACOT = {
|
|
11844
11840
|
description: _t("Inverse cotangent of a value."),
|
|
11845
11841
|
args: [arg("value (number)", _t("The value for which to calculate the inverse cotangent."))],
|
|
11846
|
-
returns: ["NUMBER"],
|
|
11847
11842
|
compute: function (value) {
|
|
11848
11843
|
const _value = toNumber(value, this.locale);
|
|
11849
11844
|
const sign = Math.sign(_value) || 1;
|
|
@@ -11862,7 +11857,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11862
11857
|
args: [
|
|
11863
11858
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")),
|
|
11864
11859
|
],
|
|
11865
|
-
returns: ["NUMBER"],
|
|
11866
11860
|
compute: function (value) {
|
|
11867
11861
|
const _value = toNumber(value, this.locale);
|
|
11868
11862
|
assert(() => Math.abs(_value) > 1, _t("The value (%s) cannot be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11878,7 +11872,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11878
11872
|
args: [
|
|
11879
11873
|
arg("value (number)", _t("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")),
|
|
11880
11874
|
],
|
|
11881
|
-
returns: ["NUMBER"],
|
|
11882
11875
|
compute: function (value) {
|
|
11883
11876
|
const _value = toNumber(value, this.locale);
|
|
11884
11877
|
assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11894,7 +11887,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11894
11887
|
args: [
|
|
11895
11888
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic sine.")),
|
|
11896
11889
|
],
|
|
11897
|
-
returns: ["NUMBER"],
|
|
11898
11890
|
compute: function (value) {
|
|
11899
11891
|
return Math.asinh(toNumber(value, this.locale));
|
|
11900
11892
|
},
|
|
@@ -11906,7 +11898,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11906
11898
|
const ATAN = {
|
|
11907
11899
|
description: _t("Inverse tangent of a value, in radians."),
|
|
11908
11900
|
args: [arg("value (number)", _t("The value for which to calculate the inverse tangent."))],
|
|
11909
|
-
returns: ["NUMBER"],
|
|
11910
11901
|
compute: function (value) {
|
|
11911
11902
|
return Math.atan(toNumber(value, this.locale));
|
|
11912
11903
|
},
|
|
@@ -11921,7 +11912,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11921
11912
|
arg("x (number)", _t("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),
|
|
11922
11913
|
arg("y (number)", _t("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),
|
|
11923
11914
|
],
|
|
11924
|
-
returns: ["NUMBER"],
|
|
11925
11915
|
compute: function (x, y) {
|
|
11926
11916
|
const _x = toNumber(x, this.locale);
|
|
11927
11917
|
const _y = toNumber(y, this.locale);
|
|
@@ -11938,7 +11928,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11938
11928
|
args: [
|
|
11939
11929
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")),
|
|
11940
11930
|
],
|
|
11941
|
-
returns: ["NUMBER"],
|
|
11942
11931
|
compute: function (value) {
|
|
11943
11932
|
const _value = toNumber(value, this.locale);
|
|
11944
11933
|
assert(() => Math.abs(_value) < 1, _t("The value (%s) must be between -1 and 1 exclusive.", _value.toString()));
|
|
@@ -11955,7 +11944,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11955
11944
|
arg("value (number)", _t("The value to round up to the nearest integer multiple of factor.")),
|
|
11956
11945
|
arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
|
|
11957
11946
|
],
|
|
11958
|
-
returns: ["NUMBER"],
|
|
11959
11947
|
compute: function (value, factor = { value: DEFAULT_FACTOR }) {
|
|
11960
11948
|
const _value = toNumber(value, this.locale);
|
|
11961
11949
|
const _factor = toNumber(factor, this.locale);
|
|
@@ -11990,7 +11978,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11990
11978
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
|
|
11991
11979
|
arg(`mode (number, default=${DEFAULT_MODE})`, _t("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")),
|
|
11992
11980
|
],
|
|
11993
|
-
returns: ["NUMBER"],
|
|
11994
11981
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
|
|
11995
11982
|
const _significance = toNumber(significance, this.locale);
|
|
11996
11983
|
const _number = toNumber(number, this.locale);
|
|
@@ -12011,7 +11998,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12011
11998
|
arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
|
|
12012
11999
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12013
12000
|
],
|
|
12014
|
-
returns: ["NUMBER"],
|
|
12015
12001
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12016
12002
|
const _significance = toNumber(significance, this.locale);
|
|
12017
12003
|
const _number = toNumber(number, this.locale);
|
|
@@ -12028,7 +12014,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12028
12014
|
const COS = {
|
|
12029
12015
|
description: _t("Cosine of an angle provided in radians."),
|
|
12030
12016
|
args: [arg("angle (number)", _t("The angle to find the cosine of, in radians."))],
|
|
12031
|
-
returns: ["NUMBER"],
|
|
12032
12017
|
compute: function (angle) {
|
|
12033
12018
|
return Math.cos(toNumber(angle, this.locale));
|
|
12034
12019
|
},
|
|
@@ -12040,7 +12025,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12040
12025
|
const COSH = {
|
|
12041
12026
|
description: _t("Hyperbolic cosine of any real number."),
|
|
12042
12027
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosine of."))],
|
|
12043
|
-
returns: ["NUMBER"],
|
|
12044
12028
|
compute: function (value) {
|
|
12045
12029
|
return Math.cosh(toNumber(value, this.locale));
|
|
12046
12030
|
},
|
|
@@ -12052,7 +12036,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12052
12036
|
const COT = {
|
|
12053
12037
|
description: _t("Cotangent of an angle provided in radians."),
|
|
12054
12038
|
args: [arg("angle (number)", _t("The angle to find the cotangent of, in radians."))],
|
|
12055
|
-
returns: ["NUMBER"],
|
|
12056
12039
|
compute: function (angle) {
|
|
12057
12040
|
const _angle = toNumber(angle, this.locale);
|
|
12058
12041
|
assertNotZero(_angle);
|
|
@@ -12066,7 +12049,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12066
12049
|
const COTH = {
|
|
12067
12050
|
description: _t("Hyperbolic cotangent of any real number."),
|
|
12068
12051
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cotangent of."))],
|
|
12069
|
-
returns: ["NUMBER"],
|
|
12070
12052
|
compute: function (value) {
|
|
12071
12053
|
const _value = toNumber(value, this.locale);
|
|
12072
12054
|
assertNotZero(_value);
|
|
@@ -12083,7 +12065,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12083
12065
|
arg("value1 (any, range)", _t("The first value or range in which to count the number of blanks.")),
|
|
12084
12066
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges in which to count the number of blanks.")),
|
|
12085
12067
|
],
|
|
12086
|
-
returns: ["NUMBER"],
|
|
12087
12068
|
compute: function (...args) {
|
|
12088
12069
|
return reduceAny(args, (acc, a) => {
|
|
12089
12070
|
if (a === undefined) {
|
|
@@ -12109,7 +12090,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12109
12090
|
arg("range (range)", _t("The range that is tested against criterion.")),
|
|
12110
12091
|
arg("criterion (string)", _t("The pattern or test to apply to range.")),
|
|
12111
12092
|
],
|
|
12112
|
-
returns: ["NUMBER"],
|
|
12113
12093
|
compute: function (...args) {
|
|
12114
12094
|
let count = 0;
|
|
12115
12095
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12130,7 +12110,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12130
12110
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
|
|
12131
12111
|
arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
|
|
12132
12112
|
],
|
|
12133
|
-
returns: ["NUMBER"],
|
|
12134
12113
|
compute: function (...args) {
|
|
12135
12114
|
let count = 0;
|
|
12136
12115
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12149,7 +12128,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12149
12128
|
arg("value1 (any, range)", _t("The first value or range to consider for uniqueness.")),
|
|
12150
12129
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider for uniqueness.")),
|
|
12151
12130
|
],
|
|
12152
|
-
returns: ["NUMBER"],
|
|
12153
12131
|
compute: function (...args) {
|
|
12154
12132
|
return countUnique(args);
|
|
12155
12133
|
},
|
|
@@ -12166,7 +12144,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12166
12144
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
|
|
12167
12145
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
12168
12146
|
],
|
|
12169
|
-
returns: ["NUMBER"],
|
|
12170
12147
|
compute: function (range, ...args) {
|
|
12171
12148
|
let uniqueValues = new Set();
|
|
12172
12149
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12184,7 +12161,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12184
12161
|
const CSC = {
|
|
12185
12162
|
description: _t("Cosecant of an angle provided in radians."),
|
|
12186
12163
|
args: [arg("angle (number)", _t("The angle to find the cosecant of, in radians."))],
|
|
12187
|
-
returns: ["NUMBER"],
|
|
12188
12164
|
compute: function (angle) {
|
|
12189
12165
|
const _angle = toNumber(angle, this.locale);
|
|
12190
12166
|
assertNotZero(_angle);
|
|
@@ -12198,7 +12174,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12198
12174
|
const CSCH = {
|
|
12199
12175
|
description: _t("Hyperbolic cosecant of any real number."),
|
|
12200
12176
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosecant of."))],
|
|
12201
|
-
returns: ["NUMBER"],
|
|
12202
12177
|
compute: function (value) {
|
|
12203
12178
|
const _value = toNumber(value, this.locale);
|
|
12204
12179
|
assertNotZero(_value);
|
|
@@ -12215,7 +12190,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12215
12190
|
arg("value (string)", _t("The number to convert.")),
|
|
12216
12191
|
arg("base (number)", _t("The base to convert the value from.")),
|
|
12217
12192
|
],
|
|
12218
|
-
returns: ["NUMBER"],
|
|
12219
12193
|
compute: function (value, base) {
|
|
12220
12194
|
let _base = toNumber(base, this.locale);
|
|
12221
12195
|
_base = Math.floor(_base);
|
|
@@ -12242,7 +12216,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12242
12216
|
const DEGREES = {
|
|
12243
12217
|
description: _t("Converts an angle value in radians to degrees."),
|
|
12244
12218
|
args: [arg("angle (number)", _t("The angle to convert from radians to degrees."))],
|
|
12245
|
-
returns: ["NUMBER"],
|
|
12246
12219
|
compute: function (angle) {
|
|
12247
12220
|
return (toNumber(angle, this.locale) * 180) / Math.PI;
|
|
12248
12221
|
},
|
|
@@ -12254,7 +12227,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12254
12227
|
const EXP = {
|
|
12255
12228
|
description: _t("Euler's number, e (~2.718) raised to a power."),
|
|
12256
12229
|
args: [arg("value (number)", _t("The exponent to raise e."))],
|
|
12257
|
-
returns: ["NUMBER"],
|
|
12258
12230
|
compute: function (value) {
|
|
12259
12231
|
return Math.exp(toNumber(value, this.locale));
|
|
12260
12232
|
},
|
|
@@ -12269,7 +12241,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12269
12241
|
arg("value (number)", _t("The value to round down to the nearest integer multiple of factor.")),
|
|
12270
12242
|
arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
|
|
12271
12243
|
],
|
|
12272
|
-
returns: ["NUMBER"],
|
|
12273
12244
|
compute: function (value, factor = { value: DEFAULT_FACTOR }) {
|
|
12274
12245
|
const _value = toNumber(value, this.locale);
|
|
12275
12246
|
const _factor = toNumber(factor, this.locale);
|
|
@@ -12304,7 +12275,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12304
12275
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
|
|
12305
12276
|
arg(`mode (number, default=${DEFAULT_MODE})`, _t("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")),
|
|
12306
12277
|
],
|
|
12307
|
-
returns: ["NUMBER"],
|
|
12308
12278
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
|
|
12309
12279
|
const _significance = toNumber(significance, this.locale);
|
|
12310
12280
|
const _number = toNumber(number, this.locale);
|
|
@@ -12325,7 +12295,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12325
12295
|
arg("number (number)", _t("The value to round down to the nearest integer multiple of significance.")),
|
|
12326
12296
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12327
12297
|
],
|
|
12328
|
-
returns: ["NUMBER"],
|
|
12329
12298
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12330
12299
|
const _significance = toNumber(significance, this.locale);
|
|
12331
12300
|
const _number = toNumber(number, this.locale);
|
|
@@ -12342,7 +12311,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12342
12311
|
const ISEVEN = {
|
|
12343
12312
|
description: _t("Whether the provided value is even."),
|
|
12344
12313
|
args: [arg("value (number)", _t("The value to be verified as even."))],
|
|
12345
|
-
returns: ["BOOLEAN"],
|
|
12346
12314
|
compute: function (value) {
|
|
12347
12315
|
const _value = strictToNumber(value, this.locale);
|
|
12348
12316
|
return Math.floor(Math.abs(_value)) & 1 ? false : true;
|
|
@@ -12358,7 +12326,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12358
12326
|
arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
|
|
12359
12327
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12360
12328
|
],
|
|
12361
|
-
returns: ["NUMBER"],
|
|
12362
12329
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12363
12330
|
const _number = toNumber(number, this.locale);
|
|
12364
12331
|
const _significance = toNumber(significance, this.locale);
|
|
@@ -12375,7 +12342,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12375
12342
|
const ISODD = {
|
|
12376
12343
|
description: _t("Whether the provided value is even."),
|
|
12377
12344
|
args: [arg("value (number)", _t("The value to be verified as even."))],
|
|
12378
|
-
returns: ["BOOLEAN"],
|
|
12379
12345
|
compute: function (value) {
|
|
12380
12346
|
const _value = strictToNumber(value, this.locale);
|
|
12381
12347
|
return Math.floor(Math.abs(_value)) & 1 ? true : false;
|
|
@@ -12388,7 +12354,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12388
12354
|
const LN = {
|
|
12389
12355
|
description: _t("The logarithm of a number, base e (euler's number)."),
|
|
12390
12356
|
args: [arg("value (number)", _t("The value for which to calculate the logarithm, base e."))],
|
|
12391
|
-
returns: ["NUMBER"],
|
|
12392
12357
|
compute: function (value) {
|
|
12393
12358
|
const _value = toNumber(value, this.locale);
|
|
12394
12359
|
assert(() => _value > 0, _t("The value (%s) must be strictly positive.", _value.toString()));
|
|
@@ -12414,7 +12379,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12414
12379
|
arg("dividend (number)", _t("The number to be divided to find the remainder.")),
|
|
12415
12380
|
arg("divisor (number)", _t("The number to divide by.")),
|
|
12416
12381
|
],
|
|
12417
|
-
returns: ["NUMBER"],
|
|
12418
12382
|
compute: function (dividend, divisor) {
|
|
12419
12383
|
const _divisor = toNumber(divisor, this.locale);
|
|
12420
12384
|
const _dividend = toNumber(dividend, this.locale);
|
|
@@ -12433,7 +12397,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12433
12397
|
args: [
|
|
12434
12398
|
arg("dimension (number)", _t("An integer specifying the dimension size of the unit matrix. It must be positive.")),
|
|
12435
12399
|
],
|
|
12436
|
-
returns: ["RANGE<NUMBER>"],
|
|
12437
12400
|
compute: function (n) {
|
|
12438
12401
|
const _n = toInteger(n, this.locale);
|
|
12439
12402
|
assertPositive(_t("The argument dimension must be positive"), _n);
|
|
@@ -12447,7 +12410,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12447
12410
|
const ODD = {
|
|
12448
12411
|
description: _t("Rounds a number up to the nearest odd integer."),
|
|
12449
12412
|
args: [arg("value (number)", _t("The value to round to the next greatest odd number."))],
|
|
12450
|
-
returns: ["NUMBER"],
|
|
12451
12413
|
compute: function (value) {
|
|
12452
12414
|
const _value = toNumber(value, this.locale);
|
|
12453
12415
|
let temp = Math.ceil(Math.abs(_value));
|
|
@@ -12465,7 +12427,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12465
12427
|
const PI = {
|
|
12466
12428
|
description: _t("The number pi."),
|
|
12467
12429
|
args: [],
|
|
12468
|
-
returns: ["NUMBER"],
|
|
12469
12430
|
compute: function () {
|
|
12470
12431
|
return Math.PI;
|
|
12471
12432
|
},
|
|
@@ -12480,7 +12441,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12480
12441
|
arg("base (number)", _t("The number to raise to the exponent power.")),
|
|
12481
12442
|
arg("exponent (number)", _t("The exponent to raise base to.")),
|
|
12482
12443
|
],
|
|
12483
|
-
returns: ["NUMBER"],
|
|
12484
12444
|
compute: function (base, exponent) {
|
|
12485
12445
|
const _base = toNumber(base, this.locale);
|
|
12486
12446
|
const _exponent = toNumber(exponent, this.locale);
|
|
@@ -12498,7 +12458,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12498
12458
|
arg("factor1 (number, range<number>)", _t("The first number or range to calculate for the product.")),
|
|
12499
12459
|
arg("factor2 (number, range<number>, repeating)", _t("More numbers or ranges to calculate for the product.")),
|
|
12500
12460
|
],
|
|
12501
|
-
returns: ["NUMBER"],
|
|
12502
12461
|
compute: function (...factors) {
|
|
12503
12462
|
let count = 0;
|
|
12504
12463
|
let acc = 1;
|
|
@@ -12535,7 +12494,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12535
12494
|
const RAND = {
|
|
12536
12495
|
description: _t("A random number between 0 inclusive and 1 exclusive."),
|
|
12537
12496
|
args: [],
|
|
12538
|
-
returns: ["NUMBER"],
|
|
12539
12497
|
compute: function () {
|
|
12540
12498
|
return Math.random();
|
|
12541
12499
|
},
|
|
@@ -12553,7 +12511,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12553
12511
|
arg("max (number, default=1)", _t("The maximum number you would like returned.")),
|
|
12554
12512
|
arg("whole_number (number, default=FALSE)", _t("Return a whole number or a decimal value.")),
|
|
12555
12513
|
],
|
|
12556
|
-
returns: ["RANGE<NUMBER>"],
|
|
12557
12514
|
compute: function (rows = { value: 1 }, columns = { value: 1 }, min = { value: 0 }, max = { value: 1 }, wholeNumber = { value: false }) {
|
|
12558
12515
|
const _cols = toInteger(columns, this.locale);
|
|
12559
12516
|
const _rows = toInteger(rows, this.locale);
|
|
@@ -12591,7 +12548,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12591
12548
|
arg("low (number)", _t("The low end of the random range.")),
|
|
12592
12549
|
arg("high (number)", _t("The high end of the random range.")),
|
|
12593
12550
|
],
|
|
12594
|
-
returns: ["NUMBER"],
|
|
12595
12551
|
compute: function (low, high) {
|
|
12596
12552
|
let _low = toNumber(low, this.locale);
|
|
12597
12553
|
if (!Number.isInteger(_low)) {
|
|
@@ -12618,7 +12574,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12618
12574
|
arg("value (number)", _t("The value to round to places number of places.")),
|
|
12619
12575
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12620
12576
|
],
|
|
12621
|
-
returns: ["NUMBER"],
|
|
12622
12577
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12623
12578
|
const _value = toNumber(value, this.locale);
|
|
12624
12579
|
let _places = toNumber(places, this.locale);
|
|
@@ -12649,7 +12604,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12649
12604
|
arg("value (number)", _t("The value to round to places number of places, always rounding down.")),
|
|
12650
12605
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12651
12606
|
],
|
|
12652
|
-
returns: ["NUMBER"],
|
|
12653
12607
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12654
12608
|
const _value = toNumber(value, this.locale);
|
|
12655
12609
|
let _places = toNumber(places, this.locale);
|
|
@@ -12680,7 +12634,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12680
12634
|
arg("value (number)", _t("The value to round to places number of places, always rounding up.")),
|
|
12681
12635
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12682
12636
|
],
|
|
12683
|
-
returns: ["NUMBER"],
|
|
12684
12637
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12685
12638
|
const _value = toNumber(value, this.locale);
|
|
12686
12639
|
let _places = toNumber(places, this.locale);
|
|
@@ -12708,7 +12661,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12708
12661
|
const SEC = {
|
|
12709
12662
|
description: _t("Secant of an angle provided in radians."),
|
|
12710
12663
|
args: [arg("angle (number)", _t("The angle to find the secant of, in radians."))],
|
|
12711
|
-
returns: ["NUMBER"],
|
|
12712
12664
|
compute: function (angle) {
|
|
12713
12665
|
return 1 / Math.cos(toNumber(angle, this.locale));
|
|
12714
12666
|
},
|
|
@@ -12720,7 +12672,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12720
12672
|
const SECH = {
|
|
12721
12673
|
description: _t("Hyperbolic secant of any real number."),
|
|
12722
12674
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic secant of."))],
|
|
12723
|
-
returns: ["NUMBER"],
|
|
12724
12675
|
compute: function (value) {
|
|
12725
12676
|
return 1 / Math.cosh(toNumber(value, this.locale));
|
|
12726
12677
|
},
|
|
@@ -12732,7 +12683,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12732
12683
|
const SIN = {
|
|
12733
12684
|
description: _t("Sine of an angle provided in radians."),
|
|
12734
12685
|
args: [arg("angle (number)", _t("The angle to find the sine of, in radians."))],
|
|
12735
|
-
returns: ["NUMBER"],
|
|
12736
12686
|
compute: function (angle) {
|
|
12737
12687
|
return Math.sin(toNumber(angle, this.locale));
|
|
12738
12688
|
},
|
|
@@ -12744,7 +12694,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12744
12694
|
const SINH = {
|
|
12745
12695
|
description: _t("Hyperbolic sine of any real number."),
|
|
12746
12696
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic sine of."))],
|
|
12747
|
-
returns: ["NUMBER"],
|
|
12748
12697
|
compute: function (value) {
|
|
12749
12698
|
return Math.sinh(toNumber(value, this.locale));
|
|
12750
12699
|
},
|
|
@@ -12756,7 +12705,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12756
12705
|
const SQRT = {
|
|
12757
12706
|
description: _t("Positive square root of a positive number."),
|
|
12758
12707
|
args: [arg("value (number)", _t("The number for which to calculate the positive square root."))],
|
|
12759
|
-
returns: ["NUMBER"],
|
|
12760
12708
|
compute: function (value) {
|
|
12761
12709
|
const _value = toNumber(value, this.locale);
|
|
12762
12710
|
assert(() => _value >= 0, _t("The value (%s) must be positive or null.", _value.toString()));
|
|
@@ -12773,7 +12721,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12773
12721
|
arg("value1 (number, range<number>)", _t("The first number or range to add together.")),
|
|
12774
12722
|
arg("value2 (number, range<number>, repeating)", _t("Additional numbers or ranges to add to value1.")),
|
|
12775
12723
|
],
|
|
12776
|
-
returns: ["NUMBER"],
|
|
12777
12724
|
compute: function (...values) {
|
|
12778
12725
|
const v1 = values[0];
|
|
12779
12726
|
return {
|
|
@@ -12793,7 +12740,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12793
12740
|
arg("criterion (string)", _t("The pattern or test to apply to range.")),
|
|
12794
12741
|
arg("sum_range (range, default=criteria_range)", _t("The range to be summed, if different from range.")),
|
|
12795
12742
|
],
|
|
12796
|
-
returns: ["NUMBER"],
|
|
12797
12743
|
compute: function (criteriaRange, criterion, sumRange) {
|
|
12798
12744
|
if (sumRange === undefined) {
|
|
12799
12745
|
sumRange = criteriaRange;
|
|
@@ -12821,7 +12767,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12821
12767
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges to check.")),
|
|
12822
12768
|
arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
|
|
12823
12769
|
],
|
|
12824
|
-
returns: ["NUMBER"],
|
|
12825
12770
|
compute: function (sumRange, ...criters) {
|
|
12826
12771
|
let sum = 0;
|
|
12827
12772
|
visitMatchingRanges(criters, (i, j) => {
|
|
@@ -12840,7 +12785,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12840
12785
|
const TAN = {
|
|
12841
12786
|
description: _t("Tangent of an angle provided in radians."),
|
|
12842
12787
|
args: [arg("angle (number)", _t("The angle to find the tangent of, in radians."))],
|
|
12843
|
-
returns: ["NUMBER"],
|
|
12844
12788
|
compute: function (angle) {
|
|
12845
12789
|
return Math.tan(toNumber(angle, this.locale));
|
|
12846
12790
|
},
|
|
@@ -12852,7 +12796,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12852
12796
|
const TANH = {
|
|
12853
12797
|
description: _t("Hyperbolic tangent of any real number."),
|
|
12854
12798
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic tangent of."))],
|
|
12855
|
-
returns: ["NUMBER"],
|
|
12856
12799
|
compute: function (value) {
|
|
12857
12800
|
return Math.tanh(toNumber(value, this.locale));
|
|
12858
12801
|
},
|
|
@@ -12876,7 +12819,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12876
12819
|
arg("value (number)", _t("The value to be truncated.")),
|
|
12877
12820
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of significant digits to the right of the decimal point to retain.")),
|
|
12878
12821
|
],
|
|
12879
|
-
returns: ["NUMBER"],
|
|
12880
12822
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12881
12823
|
const _value = toNumber(value, this.locale);
|
|
12882
12824
|
const _places = toNumber(places, this.locale);
|
|
@@ -12890,7 +12832,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12890
12832
|
const INT = {
|
|
12891
12833
|
description: _t("Rounds a number down to the nearest integer that is less than or equal to it."),
|
|
12892
12834
|
args: [arg("value (number)", _t("The number to round down to the nearest integer."))],
|
|
12893
|
-
returns: ["NUMBER"],
|
|
12894
12835
|
compute: function (value) {
|
|
12895
12836
|
return Math.floor(toNumber(value, this.locale));
|
|
12896
12837
|
},
|
|
@@ -13249,7 +13190,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13249
13190
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
13250
13191
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
13251
13192
|
],
|
|
13252
|
-
returns: ["NUMBER"],
|
|
13253
13193
|
compute: function (...values) {
|
|
13254
13194
|
let count = 0;
|
|
13255
13195
|
const sum = reduceNumbers(values, (acc, a) => {
|
|
@@ -13271,7 +13211,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13271
13211
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
|
|
13272
13212
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
|
|
13273
13213
|
],
|
|
13274
|
-
returns: ["NUMBER"],
|
|
13275
13214
|
compute: function (...values) {
|
|
13276
13215
|
return {
|
|
13277
13216
|
value: average(values, this.locale),
|
|
@@ -13293,7 +13232,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13293
13232
|
arg("additional_values (number, range<number>, repeating)", _t("Additional values to average.")),
|
|
13294
13233
|
arg("additional_weights (number, range<number>, repeating)", _t("Additional weights.")),
|
|
13295
13234
|
],
|
|
13296
|
-
returns: ["NUMBER"],
|
|
13297
13235
|
compute: function (...args) {
|
|
13298
13236
|
let sum = 0;
|
|
13299
13237
|
let count = 0;
|
|
@@ -13341,7 +13279,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13341
13279
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
|
|
13342
13280
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
|
|
13343
13281
|
],
|
|
13344
|
-
returns: ["NUMBER"],
|
|
13345
13282
|
compute: function (...args) {
|
|
13346
13283
|
let count = 0;
|
|
13347
13284
|
const sum = reduceNumbersTextAs0(args, (acc, a) => {
|
|
@@ -13366,7 +13303,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13366
13303
|
arg("criterion (string)", _t("The pattern or test to apply to criteria_range.")),
|
|
13367
13304
|
arg("average_range (number, range<number>, default=criteria_range)", _t("The range to average. If not included, criteria_range is used for the average instead.")),
|
|
13368
13305
|
],
|
|
13369
|
-
returns: ["NUMBER"],
|
|
13370
13306
|
compute: function (criteriaRange, criterion, averageRange) {
|
|
13371
13307
|
const _averageRange = averageRange === undefined ? toMatrix(criteriaRange) : toMatrix(averageRange);
|
|
13372
13308
|
let count = 0;
|
|
@@ -13395,7 +13331,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13395
13331
|
arg("criteria_range2 (any, range, repeating)", _t("Additional criteria_range and criterion to check.")),
|
|
13396
13332
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13397
13333
|
],
|
|
13398
|
-
returns: ["NUMBER"],
|
|
13399
13334
|
compute: function (averageRange, ...args) {
|
|
13400
13335
|
const _averageRange = toMatrix(averageRange);
|
|
13401
13336
|
let count = 0;
|
|
@@ -13421,7 +13356,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13421
13356
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when counting.")),
|
|
13422
13357
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when counting.")),
|
|
13423
13358
|
],
|
|
13424
|
-
returns: ["NUMBER"],
|
|
13425
13359
|
compute: function (...values) {
|
|
13426
13360
|
return countNumbers(values, this.locale);
|
|
13427
13361
|
},
|
|
@@ -13436,7 +13370,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13436
13370
|
arg("value1 (any, range)", _t("The first value or range to consider when counting.")),
|
|
13437
13371
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when counting.")),
|
|
13438
13372
|
],
|
|
13439
|
-
returns: ["NUMBER"],
|
|
13440
13373
|
compute: function (...values) {
|
|
13441
13374
|
return countAny(values);
|
|
13442
13375
|
},
|
|
@@ -13453,7 +13386,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13453
13386
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13454
13387
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13455
13388
|
],
|
|
13456
|
-
returns: ["NUMBER"],
|
|
13457
13389
|
compute: function (dataY, dataX) {
|
|
13458
13390
|
return covariance(dataY, dataX, false);
|
|
13459
13391
|
},
|
|
@@ -13468,7 +13400,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13468
13400
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13469
13401
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13470
13402
|
],
|
|
13471
|
-
returns: ["NUMBER"],
|
|
13472
13403
|
compute: function (dataY, dataX) {
|
|
13473
13404
|
return covariance(dataY, dataX, false);
|
|
13474
13405
|
},
|
|
@@ -13483,7 +13414,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13483
13414
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13484
13415
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13485
13416
|
],
|
|
13486
|
-
returns: ["NUMBER"],
|
|
13487
13417
|
compute: function (dataY, dataX) {
|
|
13488
13418
|
return covariance(dataY, dataX, true);
|
|
13489
13419
|
},
|
|
@@ -13499,7 +13429,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13499
13429
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13500
13430
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13501
13431
|
],
|
|
13502
|
-
returns: ["NUMBER"],
|
|
13503
13432
|
compute: function (x, dataY, dataX) {
|
|
13504
13433
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13505
13434
|
return predictLinearValues([flatDataY], [flatDataX], matrixMap(toMatrix(x), (value) => toNumber(value, this.locale)), true);
|
|
@@ -13517,7 +13446,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13517
13446
|
arg("new_data_x (any, range, default=known_data_x)", _t("The data points to return the y values for on the ideal curve fit.")),
|
|
13518
13447
|
arg("b (boolean, default=TRUE)", _t("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.")),
|
|
13519
13448
|
],
|
|
13520
|
-
returns: ["NUMBER"],
|
|
13521
13449
|
compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
|
|
13522
13450
|
return expM(predictLinearValues(logM(toNumberMatrix(knownDataY, "the first argument (known_data_y)")), toNumberMatrix(knownDataX, "the second argument (known_data_x)"), toNumberMatrix(newDataX, "the third argument (new_data_y)"), toBoolean(b)));
|
|
13523
13451
|
},
|
|
@@ -13531,7 +13459,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13531
13459
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13532
13460
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13533
13461
|
],
|
|
13534
|
-
returns: ["NUMBER"],
|
|
13535
13462
|
compute: function (dataY, dataX) {
|
|
13536
13463
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13537
13464
|
const [[], [intercept]] = fullLinearRegression([flatDataX], [flatDataY]);
|
|
@@ -13548,7 +13475,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13548
13475
|
arg("data (any, range)", _t("Array or range containing the dataset to consider.")),
|
|
13549
13476
|
arg("n (number)", _t("The rank from largest to smallest of the element to return.")),
|
|
13550
13477
|
],
|
|
13551
|
-
returns: ["NUMBER"],
|
|
13552
13478
|
compute: function (data, n) {
|
|
13553
13479
|
const _n = Math.trunc(toNumber(n?.value, this.locale));
|
|
13554
13480
|
let largests = [];
|
|
@@ -13583,7 +13509,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13583
13509
|
arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
|
|
13584
13510
|
arg("verbose (boolean, default=FALSE)", _t("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept")),
|
|
13585
13511
|
],
|
|
13586
|
-
returns: ["NUMBER"],
|
|
13587
13512
|
compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
|
|
13588
13513
|
return fullLinearRegression(toNumberMatrix(dataX, "the first argument (data_y)"), toNumberMatrix(dataY, "the second argument (data_x)"), toBoolean(calculateB), toBoolean(verbose));
|
|
13589
13514
|
},
|
|
@@ -13600,7 +13525,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13600
13525
|
arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
|
|
13601
13526
|
arg("verbose (boolean, default=FALSE)", _t("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept")),
|
|
13602
13527
|
],
|
|
13603
|
-
returns: ["NUMBER"],
|
|
13604
13528
|
compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
|
|
13605
13529
|
const coeffs = fullLinearRegression(toNumberMatrix(dataX, "the second argument (data_x)"), logM(toNumberMatrix(dataY, "the first argument (data_y)")), toBoolean(calculateB), toBoolean(verbose));
|
|
13606
13530
|
for (let i = 0; i < coeffs.length; i++) {
|
|
@@ -13619,7 +13543,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13619
13543
|
arg("data_x (range)", _t("The range representing the array or matrix of observed data.")),
|
|
13620
13544
|
arg("data_y (range)", _t("The range representing the array or matrix of predicted data.")),
|
|
13621
13545
|
],
|
|
13622
|
-
returns: ["NUMBER"],
|
|
13623
13546
|
compute: function (dataX, dataY) {
|
|
13624
13547
|
const flatX = dataX.flat();
|
|
13625
13548
|
const flatY = dataY.flat();
|
|
@@ -13663,7 +13586,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13663
13586
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the maximum value.")),
|
|
13664
13587
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
|
|
13665
13588
|
],
|
|
13666
|
-
returns: ["NUMBER"],
|
|
13667
13589
|
compute: function (...values) {
|
|
13668
13590
|
return {
|
|
13669
13591
|
value: max(values, this.locale),
|
|
@@ -13681,7 +13603,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13681
13603
|
arg("value1 (any, range)", _t("The first value or range to consider when calculating the maximum value.")),
|
|
13682
13604
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
|
|
13683
13605
|
],
|
|
13684
|
-
returns: ["NUMBER"],
|
|
13685
13606
|
compute: function (...args) {
|
|
13686
13607
|
const maxa = reduceNumbersTextAs0(args, (acc, a) => {
|
|
13687
13608
|
return Math.max(a, acc);
|
|
@@ -13702,7 +13623,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13702
13623
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
|
|
13703
13624
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13704
13625
|
],
|
|
13705
|
-
returns: ["NUMBER"],
|
|
13706
13626
|
compute: function (range, ...args) {
|
|
13707
13627
|
let result = -Infinity;
|
|
13708
13628
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -13724,7 +13644,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13724
13644
|
arg("value1 (any, range)", _t("The first value or range to consider when calculating the median value.")),
|
|
13725
13645
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the median value.")),
|
|
13726
13646
|
],
|
|
13727
|
-
returns: ["NUMBER"],
|
|
13728
13647
|
compute: function (...values) {
|
|
13729
13648
|
let data = [];
|
|
13730
13649
|
visitNumbers(values, (value) => {
|
|
@@ -13746,7 +13665,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13746
13665
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
|
|
13747
13666
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
|
|
13748
13667
|
],
|
|
13749
|
-
returns: ["NUMBER"],
|
|
13750
13668
|
compute: function (...values) {
|
|
13751
13669
|
return {
|
|
13752
13670
|
value: min(values, this.locale),
|
|
@@ -13764,7 +13682,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13764
13682
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
|
|
13765
13683
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
|
|
13766
13684
|
],
|
|
13767
|
-
returns: ["NUMBER"],
|
|
13768
13685
|
compute: function (...args) {
|
|
13769
13686
|
const mina = reduceNumbersTextAs0(args, (acc, a) => {
|
|
13770
13687
|
return Math.min(a, acc);
|
|
@@ -13785,7 +13702,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13785
13702
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
|
|
13786
13703
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13787
13704
|
],
|
|
13788
|
-
returns: ["NUMBER"],
|
|
13789
13705
|
compute: function (range, ...args) {
|
|
13790
13706
|
let result = Infinity;
|
|
13791
13707
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -13828,7 +13744,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13828
13744
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13829
13745
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13830
13746
|
],
|
|
13831
|
-
returns: ["NUMBER"],
|
|
13832
13747
|
compute: function (dataY, dataX) {
|
|
13833
13748
|
return pearson(dataY, dataX);
|
|
13834
13749
|
},
|
|
@@ -13845,7 +13760,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13845
13760
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13846
13761
|
arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
|
|
13847
13762
|
],
|
|
13848
|
-
returns: ["NUMBER"],
|
|
13849
13763
|
compute: function (data, percentile) {
|
|
13850
13764
|
return PERCENTILE_INC.compute.bind(this)(data, percentile);
|
|
13851
13765
|
},
|
|
@@ -13860,7 +13774,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13860
13774
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13861
13775
|
arg("percentile (number)", _t("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")),
|
|
13862
13776
|
],
|
|
13863
|
-
returns: ["NUMBER"],
|
|
13864
13777
|
compute: function (data, percentile) {
|
|
13865
13778
|
return {
|
|
13866
13779
|
value: centile([data], percentile, false, this.locale),
|
|
@@ -13878,7 +13791,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13878
13791
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13879
13792
|
arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
|
|
13880
13793
|
],
|
|
13881
|
-
returns: ["NUMBER"],
|
|
13882
13794
|
compute: function (data, percentile) {
|
|
13883
13795
|
return {
|
|
13884
13796
|
value: centile([data], percentile, true, this.locale),
|
|
@@ -13898,7 +13810,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13898
13810
|
arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
|
|
13899
13811
|
arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
|
|
13900
13812
|
],
|
|
13901
|
-
returns: ["RANGE<NUMBER>"],
|
|
13902
13813
|
compute: function (dataY, dataX, order, intercept = { value: true }) {
|
|
13903
13814
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13904
13815
|
return polynomialRegression(flatDataY, flatDataX, toNumber(order, this.locale), toBoolean(intercept));
|
|
@@ -13917,7 +13828,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13917
13828
|
arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
|
|
13918
13829
|
arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
|
|
13919
13830
|
],
|
|
13920
|
-
returns: ["NUMBER"],
|
|
13921
13831
|
compute: function (x, dataY, dataX, order, intercept = { value: true }) {
|
|
13922
13832
|
const _order = toNumber(order, this.locale);
|
|
13923
13833
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
@@ -13935,7 +13845,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13935
13845
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13936
13846
|
arg("quartile_number (number)", _t("Which quartile value to return.")),
|
|
13937
13847
|
],
|
|
13938
|
-
returns: ["NUMBER"],
|
|
13939
13848
|
compute: function (data, quartileNumber) {
|
|
13940
13849
|
return QUARTILE_INC.compute.bind(this)(data, quartileNumber);
|
|
13941
13850
|
},
|
|
@@ -13950,7 +13859,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13950
13859
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13951
13860
|
arg("quartile_number (number)", _t("Which quartile value, exclusive of 0 and 4, to return.")),
|
|
13952
13861
|
],
|
|
13953
|
-
returns: ["NUMBER"],
|
|
13954
13862
|
compute: function (data, quartileNumber) {
|
|
13955
13863
|
const _quartileNumber = Math.trunc(toNumber(quartileNumber, this.locale));
|
|
13956
13864
|
const percent = { value: 0.25 * _quartileNumber };
|
|
@@ -13970,7 +13878,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13970
13878
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13971
13879
|
arg("quartile_number (number)", _t("Which quartile value to return.")),
|
|
13972
13880
|
],
|
|
13973
|
-
returns: ["NUMBER"],
|
|
13974
13881
|
compute: function (data, quartileNumber) {
|
|
13975
13882
|
const percent = { value: 0.25 * Math.trunc(toNumber(quartileNumber, this.locale)) };
|
|
13976
13883
|
return {
|
|
@@ -13989,7 +13896,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13989
13896
|
arg("data (range)", _t("The range containing the dataset to consider.")),
|
|
13990
13897
|
arg("is_ascending (boolean, default=FALSE)", _t("Whether to consider the values in data in descending or ascending order.")),
|
|
13991
13898
|
],
|
|
13992
|
-
returns: ["ANY"],
|
|
13993
13899
|
compute: function (value, data, isAscending = { value: false }) {
|
|
13994
13900
|
const _isAscending = toBoolean(isAscending);
|
|
13995
13901
|
const _value = toNumber(value, this.locale);
|
|
@@ -14025,7 +13931,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14025
13931
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14026
13932
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14027
13933
|
],
|
|
14028
|
-
returns: ["NUMBER"],
|
|
14029
13934
|
compute: function (dataY, dataX) {
|
|
14030
13935
|
return Math.pow(pearson(dataX, dataY), 2.0);
|
|
14031
13936
|
},
|
|
@@ -14040,7 +13945,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14040
13945
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14041
13946
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14042
13947
|
],
|
|
14043
|
-
returns: ["NUMBER"],
|
|
14044
13948
|
compute: function (dataY, dataX) {
|
|
14045
13949
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14046
13950
|
const [[slope]] = fullLinearRegression([flatDataX], [flatDataY]);
|
|
@@ -14057,7 +13961,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14057
13961
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
14058
13962
|
arg("n (number)", _t("The rank from smallest to largest of the element to return.")),
|
|
14059
13963
|
],
|
|
14060
|
-
returns: ["NUMBER"],
|
|
14061
13964
|
compute: function (data, n) {
|
|
14062
13965
|
const _n = Math.trunc(toNumber(n?.value, this.locale));
|
|
14063
13966
|
let largests = [];
|
|
@@ -14090,7 +13993,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14090
13993
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14091
13994
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14092
13995
|
],
|
|
14093
|
-
returns: ["NUMBER"],
|
|
14094
13996
|
compute: function (dataX, dataY) {
|
|
14095
13997
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14096
13998
|
const n = flatDataX.length;
|
|
@@ -14117,7 +14019,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14117
14019
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14118
14020
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14119
14021
|
],
|
|
14120
|
-
returns: ["NUMBER"],
|
|
14121
14022
|
compute: function (...args) {
|
|
14122
14023
|
return Math.sqrt(VAR.compute.bind(this)(...args));
|
|
14123
14024
|
},
|
|
@@ -14132,7 +14033,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14132
14033
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14133
14034
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14134
14035
|
],
|
|
14135
|
-
returns: ["NUMBER"],
|
|
14136
14036
|
compute: function (...args) {
|
|
14137
14037
|
return Math.sqrt(VAR_P.compute.bind(this)(...args));
|
|
14138
14038
|
},
|
|
@@ -14147,7 +14047,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14147
14047
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14148
14048
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14149
14049
|
],
|
|
14150
|
-
returns: ["NUMBER"],
|
|
14151
14050
|
compute: function (...args) {
|
|
14152
14051
|
return Math.sqrt(VAR_S.compute.bind(this)(...args));
|
|
14153
14052
|
},
|
|
@@ -14162,7 +14061,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14162
14061
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14163
14062
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14164
14063
|
],
|
|
14165
|
-
returns: ["NUMBER"],
|
|
14166
14064
|
compute: function (...args) {
|
|
14167
14065
|
return Math.sqrt(VARA.compute.bind(this)(...args));
|
|
14168
14066
|
},
|
|
@@ -14177,7 +14075,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14177
14075
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14178
14076
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14179
14077
|
],
|
|
14180
|
-
returns: ["NUMBER"],
|
|
14181
14078
|
compute: function (...args) {
|
|
14182
14079
|
return Math.sqrt(VARP.compute.bind(this)(...args));
|
|
14183
14080
|
},
|
|
@@ -14192,7 +14089,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14192
14089
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14193
14090
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14194
14091
|
],
|
|
14195
|
-
returns: ["NUMBER"],
|
|
14196
14092
|
compute: function (...args) {
|
|
14197
14093
|
return Math.sqrt(VARPA.compute.bind(this)(...args));
|
|
14198
14094
|
},
|
|
@@ -14207,7 +14103,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14207
14103
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14208
14104
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14209
14105
|
],
|
|
14210
|
-
returns: ["NUMBER"],
|
|
14211
14106
|
compute: function (dataY, dataX) {
|
|
14212
14107
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14213
14108
|
const data = fullLinearRegression([flatDataX], [flatDataY], true, true);
|
|
@@ -14226,7 +14121,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14226
14121
|
arg("new_data_x (number, range<number>, optional, default=known_data_x)", _t("The data points to return the y values for on the ideal curve fit.")),
|
|
14227
14122
|
arg("b (boolean, optional, default=TRUE)", _t("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.")),
|
|
14228
14123
|
],
|
|
14229
|
-
returns: ["NUMBER"],
|
|
14230
14124
|
compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
|
|
14231
14125
|
return predictLinearValues(toNumberMatrix(knownDataY, "the first argument (known_data_y)"), toNumberMatrix(knownDataX, "the second argument (known_data_x)"), toNumberMatrix(newDataX, "the third argument (new_data_y)"), toBoolean(b));
|
|
14232
14126
|
},
|
|
@@ -14240,7 +14134,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14240
14134
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14241
14135
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14242
14136
|
],
|
|
14243
|
-
returns: ["NUMBER"],
|
|
14244
14137
|
compute: function (...args) {
|
|
14245
14138
|
return variance(args, true, false, this.locale);
|
|
14246
14139
|
},
|
|
@@ -14255,7 +14148,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14255
14148
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14256
14149
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14257
14150
|
],
|
|
14258
|
-
returns: ["NUMBER"],
|
|
14259
14151
|
compute: function (...args) {
|
|
14260
14152
|
return variance(args, false, false, this.locale);
|
|
14261
14153
|
},
|
|
@@ -14270,7 +14162,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14270
14162
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14271
14163
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14272
14164
|
],
|
|
14273
|
-
returns: ["NUMBER"],
|
|
14274
14165
|
compute: function (...args) {
|
|
14275
14166
|
return variance(args, true, false, this.locale);
|
|
14276
14167
|
},
|
|
@@ -14285,7 +14176,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14285
14176
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14286
14177
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14287
14178
|
],
|
|
14288
|
-
returns: ["NUMBER"],
|
|
14289
14179
|
compute: function (...args) {
|
|
14290
14180
|
return variance(args, true, true, this.locale);
|
|
14291
14181
|
},
|
|
@@ -14300,7 +14190,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14300
14190
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14301
14191
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14302
14192
|
],
|
|
14303
|
-
returns: ["NUMBER"],
|
|
14304
14193
|
compute: function (...args) {
|
|
14305
14194
|
return variance(args, false, false, this.locale);
|
|
14306
14195
|
},
|
|
@@ -14315,7 +14204,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14315
14204
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14316
14205
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14317
14206
|
],
|
|
14318
|
-
returns: ["NUMBER"],
|
|
14319
14207
|
compute: function (...args) {
|
|
14320
14208
|
return variance(args, false, true, this.locale);
|
|
14321
14209
|
},
|
|
@@ -14481,7 +14369,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14481
14369
|
const DAVERAGE = {
|
|
14482
14370
|
description: _t("Average of a set of values from a table-like range."),
|
|
14483
14371
|
args: databaseArgs,
|
|
14484
|
-
returns: ["NUMBER"],
|
|
14485
14372
|
compute: function (database, field, criteria) {
|
|
14486
14373
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14487
14374
|
return AVERAGE.compute.bind(this)([cells]);
|
|
@@ -14494,7 +14381,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14494
14381
|
const DCOUNT = {
|
|
14495
14382
|
description: _t("Counts values from a table-like range."),
|
|
14496
14383
|
args: databaseArgs,
|
|
14497
|
-
returns: ["NUMBER"],
|
|
14498
14384
|
compute: function (database, field, criteria) {
|
|
14499
14385
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14500
14386
|
return COUNT.compute.bind(this)([cells]);
|
|
@@ -14507,7 +14393,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14507
14393
|
const DCOUNTA = {
|
|
14508
14394
|
description: _t("Counts values and text from a table-like range."),
|
|
14509
14395
|
args: databaseArgs,
|
|
14510
|
-
returns: ["NUMBER"],
|
|
14511
14396
|
compute: function (database, field, criteria) {
|
|
14512
14397
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14513
14398
|
return COUNTA.compute.bind(this)([cells]);
|
|
@@ -14520,7 +14405,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14520
14405
|
const DGET = {
|
|
14521
14406
|
description: _t("Single value from a table-like range."),
|
|
14522
14407
|
args: databaseArgs,
|
|
14523
|
-
returns: ["NUMBER"],
|
|
14524
14408
|
compute: function (database, field, criteria) {
|
|
14525
14409
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14526
14410
|
assert(() => cells.length === 1, _t("More than one match found in DGET evaluation."));
|
|
@@ -14534,7 +14418,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14534
14418
|
const DMAX = {
|
|
14535
14419
|
description: _t("Maximum of values from a table-like range."),
|
|
14536
14420
|
args: databaseArgs,
|
|
14537
|
-
returns: ["NUMBER"],
|
|
14538
14421
|
compute: function (database, field, criteria) {
|
|
14539
14422
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14540
14423
|
return MAX.compute.bind(this)([cells]);
|
|
@@ -14547,7 +14430,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14547
14430
|
const DMIN = {
|
|
14548
14431
|
description: _t("Minimum of values from a table-like range."),
|
|
14549
14432
|
args: databaseArgs,
|
|
14550
|
-
returns: ["NUMBER"],
|
|
14551
14433
|
compute: function (database, field, criteria) {
|
|
14552
14434
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14553
14435
|
return MIN.compute.bind(this)([cells]);
|
|
@@ -14560,7 +14442,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14560
14442
|
const DPRODUCT = {
|
|
14561
14443
|
description: _t("Product of values from a table-like range."),
|
|
14562
14444
|
args: databaseArgs,
|
|
14563
|
-
returns: ["NUMBER"],
|
|
14564
14445
|
compute: function (database, field, criteria) {
|
|
14565
14446
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14566
14447
|
return PRODUCT.compute.bind(this)([cells]);
|
|
@@ -14573,7 +14454,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14573
14454
|
const DSTDEV = {
|
|
14574
14455
|
description: _t("Standard deviation of population sample from table."),
|
|
14575
14456
|
args: databaseArgs,
|
|
14576
|
-
returns: ["NUMBER"],
|
|
14577
14457
|
compute: function (database, field, criteria) {
|
|
14578
14458
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14579
14459
|
return STDEV.compute.bind(this)([cells]);
|
|
@@ -14586,7 +14466,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14586
14466
|
const DSTDEVP = {
|
|
14587
14467
|
description: _t("Standard deviation of entire population from table."),
|
|
14588
14468
|
args: databaseArgs,
|
|
14589
|
-
returns: ["NUMBER"],
|
|
14590
14469
|
compute: function (database, field, criteria) {
|
|
14591
14470
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14592
14471
|
return STDEVP.compute.bind(this)([cells]);
|
|
@@ -14599,7 +14478,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14599
14478
|
const DSUM = {
|
|
14600
14479
|
description: _t("Sum of values from a table-like range."),
|
|
14601
14480
|
args: databaseArgs,
|
|
14602
|
-
returns: ["NUMBER"],
|
|
14603
14481
|
compute: function (database, field, criteria) {
|
|
14604
14482
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14605
14483
|
return SUM.compute.bind(this)([cells]);
|
|
@@ -14612,7 +14490,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14612
14490
|
const DVAR = {
|
|
14613
14491
|
description: _t("Variance of population sample from table-like range."),
|
|
14614
14492
|
args: databaseArgs,
|
|
14615
|
-
returns: ["NUMBER"],
|
|
14616
14493
|
compute: function (database, field, criteria) {
|
|
14617
14494
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14618
14495
|
return VAR.compute.bind(this)([cells]);
|
|
@@ -14625,7 +14502,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14625
14502
|
const DVARP = {
|
|
14626
14503
|
description: _t("Variance of a population from a table-like range."),
|
|
14627
14504
|
args: databaseArgs,
|
|
14628
|
-
returns: ["NUMBER"],
|
|
14629
14505
|
compute: function (database, field, criteria) {
|
|
14630
14506
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14631
14507
|
return VARP.compute.bind(this)([cells]);
|
|
@@ -14670,7 +14546,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14670
14546
|
arg("month (number)", _t("The month component of the date.")),
|
|
14671
14547
|
arg("day (number)", _t("The day component of the date.")),
|
|
14672
14548
|
],
|
|
14673
|
-
returns: ["DATE"],
|
|
14674
14549
|
compute: function (year, month, day) {
|
|
14675
14550
|
let _year = Math.trunc(toNumber(year, this.locale));
|
|
14676
14551
|
const _month = Math.trunc(toNumber(month, this.locale));
|
|
@@ -14701,7 +14576,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14701
14576
|
arg("end_date (date)", _t("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),
|
|
14702
14577
|
arg("unit (string)", _t('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).')),
|
|
14703
14578
|
],
|
|
14704
|
-
returns: ["NUMBER"],
|
|
14705
14579
|
compute: function (startDate, endDate, unit) {
|
|
14706
14580
|
const _unit = toString(unit).toUpperCase();
|
|
14707
14581
|
assert(() => Object.values(TIME_UNIT).includes(_unit), expectStringSetError(Object.values(TIME_UNIT), toString(unit)));
|
|
@@ -14754,7 +14628,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14754
14628
|
const DATEVALUE = {
|
|
14755
14629
|
description: _t("Converts a date string to a date value."),
|
|
14756
14630
|
args: [arg("date_string (string)", _t("The string representing the date."))],
|
|
14757
|
-
returns: ["NUMBER"],
|
|
14758
14631
|
compute: function (dateString) {
|
|
14759
14632
|
const _dateString = toString(dateString);
|
|
14760
14633
|
const internalDate = parseDateTime(_dateString, this.locale);
|
|
@@ -14769,7 +14642,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14769
14642
|
const DAY = {
|
|
14770
14643
|
description: _t("Day of the month that a specific date falls on."),
|
|
14771
14644
|
args: [arg("date (string)", _t("The date from which to extract the day."))],
|
|
14772
|
-
returns: ["NUMBER"],
|
|
14773
14645
|
compute: function (date) {
|
|
14774
14646
|
return toJsDate(date, this.locale).getDate();
|
|
14775
14647
|
},
|
|
@@ -14784,7 +14656,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14784
14656
|
arg("end_date (date)", _t("The end of the date range.")),
|
|
14785
14657
|
arg("start_date (date)", _t("The start of the date range.")),
|
|
14786
14658
|
],
|
|
14787
|
-
returns: ["NUMBER"],
|
|
14788
14659
|
compute: function (endDate, startDate) {
|
|
14789
14660
|
const _endDate = toJsDate(endDate, this.locale);
|
|
14790
14661
|
const _startDate = toJsDate(startDate, this.locale);
|
|
@@ -14804,7 +14675,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14804
14675
|
arg("end_date (date)", _t("The end date to consider in the calculation.")),
|
|
14805
14676
|
arg(`method (number, default=${DEFAULT_DAY_COUNT_METHOD})`, _t("An indicator of what day count method to use. (0) US NASD method (1) European method")),
|
|
14806
14677
|
],
|
|
14807
|
-
returns: ["NUMBER"],
|
|
14808
14678
|
compute: function (startDate, endDate, method = { value: DEFAULT_DAY_COUNT_METHOD }) {
|
|
14809
14679
|
const _startDate = Math.trunc(toNumber(startDate, this.locale));
|
|
14810
14680
|
const _endDate = Math.trunc(toNumber(endDate, this.locale));
|
|
@@ -14823,7 +14693,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14823
14693
|
arg("start_date (date)", _t("The date from which to calculate the result.")),
|
|
14824
14694
|
arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to calculate.")),
|
|
14825
14695
|
],
|
|
14826
|
-
returns: ["DATE"],
|
|
14827
14696
|
compute: function (startDate, months) {
|
|
14828
14697
|
const _startDate = toJsDate(startDate, this.locale);
|
|
14829
14698
|
const _months = Math.trunc(toNumber(months, this.locale));
|
|
@@ -14844,7 +14713,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14844
14713
|
arg("start_date (date)", _t("The date from which to calculate the result.")),
|
|
14845
14714
|
arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to consider.")),
|
|
14846
14715
|
],
|
|
14847
|
-
returns: ["DATE"],
|
|
14848
14716
|
compute: function (startDate, months) {
|
|
14849
14717
|
const _startDate = toJsDate(startDate, this.locale);
|
|
14850
14718
|
const _months = Math.trunc(toNumber(months, this.locale));
|
|
@@ -14864,7 +14732,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14864
14732
|
const HOUR = {
|
|
14865
14733
|
description: _t("Hour component of a specific time."),
|
|
14866
14734
|
args: [arg("time (date)", _t("The time from which to calculate the hour component."))],
|
|
14867
|
-
returns: ["NUMBER"],
|
|
14868
14735
|
compute: function (date) {
|
|
14869
14736
|
return toJsDate(date, this.locale).getHours();
|
|
14870
14737
|
},
|
|
@@ -14878,7 +14745,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14878
14745
|
args: [
|
|
14879
14746
|
arg("date (date)", _t("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
|
|
14880
14747
|
],
|
|
14881
|
-
returns: ["NUMBER"],
|
|
14882
14748
|
compute: function (date) {
|
|
14883
14749
|
const _date = toJsDate(date, this.locale);
|
|
14884
14750
|
const y = _date.getFullYear();
|
|
@@ -14950,7 +14816,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14950
14816
|
const MINUTE = {
|
|
14951
14817
|
description: _t("Minute component of a specific time."),
|
|
14952
14818
|
args: [arg("time (date)", _t("The time from which to calculate the minute component."))],
|
|
14953
|
-
returns: ["NUMBER"],
|
|
14954
14819
|
compute: function (date) {
|
|
14955
14820
|
return toJsDate(date, this.locale).getMinutes();
|
|
14956
14821
|
},
|
|
@@ -14962,7 +14827,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14962
14827
|
const MONTH = {
|
|
14963
14828
|
description: _t("Month of the year a specific date falls in"),
|
|
14964
14829
|
args: [arg("date (date)", _t("The date from which to extract the month."))],
|
|
14965
|
-
returns: ["NUMBER"],
|
|
14966
14830
|
compute: function (date) {
|
|
14967
14831
|
return toJsDate(date, this.locale).getMonth() + 1;
|
|
14968
14832
|
},
|
|
@@ -14978,7 +14842,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14978
14842
|
arg("end_date (date)", _t("The end date of the period from which to calculate the number of net working days.")),
|
|
14979
14843
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the date serial numbers to consider holidays.")),
|
|
14980
14844
|
],
|
|
14981
|
-
returns: ["NUMBER"],
|
|
14982
14845
|
compute: function (startDate, endDate, holidays) {
|
|
14983
14846
|
return NETWORKDAYS_INTL.compute.bind(this)(startDate, endDate, { value: 1 }, holidays);
|
|
14984
14847
|
},
|
|
@@ -15059,7 +14922,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15059
14922
|
arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
|
|
15060
14923
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider as holidays.")),
|
|
15061
14924
|
],
|
|
15062
|
-
returns: ["NUMBER"],
|
|
15063
14925
|
compute: function (startDate, endDate, weekend = { value: DEFAULT_WEEKEND }, holidays) {
|
|
15064
14926
|
const _startDate = toJsDate(startDate, this.locale);
|
|
15065
14927
|
const _endDate = toJsDate(endDate, this.locale);
|
|
@@ -15094,7 +14956,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15094
14956
|
const NOW = {
|
|
15095
14957
|
description: _t("Current date and time as a date value."),
|
|
15096
14958
|
args: [],
|
|
15097
|
-
returns: ["DATE"],
|
|
15098
14959
|
compute: function () {
|
|
15099
14960
|
const today = DateTime.now();
|
|
15100
14961
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
@@ -15112,7 +14973,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15112
14973
|
const SECOND = {
|
|
15113
14974
|
description: _t("Minute component of a specific time."),
|
|
15114
14975
|
args: [arg("time (date)", _t("The time from which to calculate the second component."))],
|
|
15115
|
-
returns: ["NUMBER"],
|
|
15116
14976
|
compute: function (date) {
|
|
15117
14977
|
return toJsDate(date, this.locale).getSeconds();
|
|
15118
14978
|
},
|
|
@@ -15128,7 +14988,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15128
14988
|
arg("minute (number)", _t("The minute component of the time.")),
|
|
15129
14989
|
arg("second (number)", _t("The second component of the time.")),
|
|
15130
14990
|
],
|
|
15131
|
-
returns: ["DATE"],
|
|
15132
14991
|
compute: function (hour, minute, second) {
|
|
15133
14992
|
let _hour = Math.trunc(toNumber(hour, this.locale));
|
|
15134
14993
|
let _minute = Math.trunc(toNumber(minute, this.locale));
|
|
@@ -15152,7 +15011,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15152
15011
|
const TIMEVALUE = {
|
|
15153
15012
|
description: _t("Converts a time string into its serial number representation."),
|
|
15154
15013
|
args: [arg("time_string (string)", _t("The string that holds the time representation."))],
|
|
15155
|
-
returns: ["NUMBER"],
|
|
15156
15014
|
compute: function (timeString) {
|
|
15157
15015
|
const _timeString = toString(timeString);
|
|
15158
15016
|
const internalDate = parseDateTime(_timeString, this.locale);
|
|
@@ -15168,7 +15026,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15168
15026
|
const TODAY = {
|
|
15169
15027
|
description: _t("Current date as a date value."),
|
|
15170
15028
|
args: [],
|
|
15171
|
-
returns: ["DATE"],
|
|
15172
15029
|
compute: function () {
|
|
15173
15030
|
const today = DateTime.now();
|
|
15174
15031
|
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
@@ -15188,7 +15045,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15188
15045
|
arg("date (date)", _t("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
|
|
15189
15046
|
arg(`type (number, default=${DEFAULT_TYPE})`, _t("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")),
|
|
15190
15047
|
],
|
|
15191
|
-
returns: ["NUMBER"],
|
|
15192
15048
|
compute: function (date, type = { value: DEFAULT_TYPE }) {
|
|
15193
15049
|
const _date = toJsDate(date, this.locale);
|
|
15194
15050
|
const _type = Math.round(toNumber(type, this.locale));
|
|
@@ -15211,7 +15067,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15211
15067
|
arg("date (date)", _t("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
|
|
15212
15068
|
arg(`type (number, default=${DEFAULT_TYPE})`, _t("A number representing the day that a week starts on. Sunday = 1.")),
|
|
15213
15069
|
],
|
|
15214
|
-
returns: ["NUMBER"],
|
|
15215
15070
|
compute: function (date, type = { value: DEFAULT_TYPE }) {
|
|
15216
15071
|
const _date = toJsDate(date, this.locale);
|
|
15217
15072
|
const _type = Math.round(toNumber(type, this.locale));
|
|
@@ -15252,7 +15107,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15252
15107
|
arg("num_days (number)", _t("The number of working days to advance from start_date. If negative, counts backwards.")),
|
|
15253
15108
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
|
|
15254
15109
|
],
|
|
15255
|
-
returns: ["NUMBER"],
|
|
15256
15110
|
compute: function (startDate, numDays, holidays = { value: null }) {
|
|
15257
15111
|
return WORKDAY_INTL.compute.bind(this)(startDate, numDays, { value: 1 }, holidays);
|
|
15258
15112
|
},
|
|
@@ -15269,7 +15123,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15269
15123
|
arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
|
|
15270
15124
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
|
|
15271
15125
|
],
|
|
15272
|
-
returns: ["DATE"],
|
|
15273
15126
|
compute: function (startDate, numDays, weekend = { value: DEFAULT_WEEKEND }, holidays) {
|
|
15274
15127
|
let _startDate = toJsDate(startDate, this.locale);
|
|
15275
15128
|
let _numDays = Math.trunc(toNumber(numDays, this.locale));
|
|
@@ -15309,7 +15162,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15309
15162
|
const YEAR = {
|
|
15310
15163
|
description: _t("Year specified by a given date."),
|
|
15311
15164
|
args: [arg("date (date)", _t("The date from which to extract the year."))],
|
|
15312
|
-
returns: ["NUMBER"],
|
|
15313
15165
|
compute: function (date) {
|
|
15314
15166
|
return toJsDate(date, this.locale).getFullYear();
|
|
15315
15167
|
},
|
|
@@ -15326,7 +15178,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15326
15178
|
arg("end_date (date)", _t("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
|
|
15327
15179
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION$1})`, _t("An indicator of what day count method to use.")),
|
|
15328
15180
|
],
|
|
15329
|
-
returns: ["NUMBER"],
|
|
15330
15181
|
compute: function (startDate, endDate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION$1 }) {
|
|
15331
15182
|
let _startDate = Math.trunc(toNumber(startDate, this.locale));
|
|
15332
15183
|
let _endDate = Math.trunc(toNumber(endDate, this.locale));
|
|
@@ -15343,7 +15194,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15343
15194
|
const MONTH_START = {
|
|
15344
15195
|
description: _t("First day of the month preceding a date."),
|
|
15345
15196
|
args: [arg("date (date)", _t("The date from which to calculate the result."))],
|
|
15346
|
-
returns: ["DATE"],
|
|
15347
15197
|
compute: function (date) {
|
|
15348
15198
|
const _startDate = toJsDate(date, this.locale);
|
|
15349
15199
|
const yStart = _startDate.getFullYear();
|
|
@@ -15361,7 +15211,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15361
15211
|
const MONTH_END = {
|
|
15362
15212
|
description: _t("Last day of the month following a date."),
|
|
15363
15213
|
args: [arg("date (date)", _t("The date from which to calculate the result."))],
|
|
15364
|
-
returns: ["DATE"],
|
|
15365
15214
|
compute: function (date) {
|
|
15366
15215
|
return EOMONTH.compute.bind(this)(date, { value: 0 });
|
|
15367
15216
|
},
|
|
@@ -15372,7 +15221,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15372
15221
|
const QUARTER = {
|
|
15373
15222
|
description: _t("Quarter of the year a specific date falls in"),
|
|
15374
15223
|
args: [arg("date (date)", _t("The date from which to extract the quarter."))],
|
|
15375
|
-
returns: ["NUMBER"],
|
|
15376
15224
|
compute: function (date) {
|
|
15377
15225
|
return Math.ceil((toJsDate(date, this.locale).getMonth() + 1) / 3);
|
|
15378
15226
|
},
|
|
@@ -15383,7 +15231,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15383
15231
|
const QUARTER_START = {
|
|
15384
15232
|
description: _t("First day of the quarter of the year a specific date falls in."),
|
|
15385
15233
|
args: [arg("date (date)", _t("The date from which to calculate the start of quarter."))],
|
|
15386
|
-
returns: ["DATE"],
|
|
15387
15234
|
compute: function (date) {
|
|
15388
15235
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15389
15236
|
const year = YEAR.compute.bind(this)(date);
|
|
@@ -15400,7 +15247,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15400
15247
|
const QUARTER_END = {
|
|
15401
15248
|
description: _t("Last day of the quarter of the year a specific date falls in."),
|
|
15402
15249
|
args: [arg("date (date)", _t("The date from which to calculate the end of quarter."))],
|
|
15403
|
-
returns: ["DATE"],
|
|
15404
15250
|
compute: function (date) {
|
|
15405
15251
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15406
15252
|
const year = YEAR.compute.bind(this)(date);
|
|
@@ -15417,7 +15263,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15417
15263
|
const YEAR_START = {
|
|
15418
15264
|
description: _t("First day of the year a specific date falls in."),
|
|
15419
15265
|
args: [arg("date (date)", _t("The date from which to calculate the start of the year."))],
|
|
15420
|
-
returns: ["DATE"],
|
|
15421
15266
|
compute: function (date) {
|
|
15422
15267
|
const year = YEAR.compute.bind(this)(date);
|
|
15423
15268
|
const jsDate = new DateTime(year, 0, 1);
|
|
@@ -15433,7 +15278,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15433
15278
|
const YEAR_END = {
|
|
15434
15279
|
description: _t("Last day of the year a specific date falls in."),
|
|
15435
15280
|
args: [arg("date (date)", _t("The date from which to calculate the end of the year."))],
|
|
15436
|
-
returns: ["DATE"],
|
|
15437
15281
|
compute: function (date) {
|
|
15438
15282
|
const year = YEAR.compute.bind(this)(date);
|
|
15439
15283
|
const jsDate = new DateTime(year + 1, 0, 0);
|
|
@@ -15490,7 +15334,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15490
15334
|
arg("number1 (number)", _t("The first number to compare.")),
|
|
15491
15335
|
arg(`number2 (number, default=${DEFAULT_DELTA_ARG})`, _t("The second number to compare.")),
|
|
15492
15336
|
],
|
|
15493
|
-
returns: ["NUMBER"],
|
|
15494
15337
|
compute: function (number1, number2 = { value: DEFAULT_DELTA_ARG }) {
|
|
15495
15338
|
const _number1 = toNumber(number1, this.locale);
|
|
15496
15339
|
const _number2 = toNumber(number2, this.locale);
|
|
@@ -15681,7 +15524,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15681
15524
|
arg("condition1 (boolean, range<boolean>)", _t("A column or row containing true or false values corresponding to the first column or row of range.")),
|
|
15682
15525
|
arg("condition2 (boolean, range<boolean>, repeating)", _t("Additional column or row containing true or false values.")),
|
|
15683
15526
|
],
|
|
15684
|
-
returns: ["RANGE<ANY>"],
|
|
15685
15527
|
compute: function (range, ...conditions) {
|
|
15686
15528
|
let _array = toMatrix(range);
|
|
15687
15529
|
const _conditionsMatrices = conditions.map((cond) => matrixMap(toMatrix(cond), (data) => data.value));
|
|
@@ -15715,7 +15557,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15715
15557
|
arg("sort_column (any, range<number>, repeating)", _t("The index of the column in range or a range outside of range containing the values by which to sort.")),
|
|
15716
15558
|
arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
|
|
15717
15559
|
],
|
|
15718
|
-
returns: ["RANGE"],
|
|
15719
15560
|
compute: function (range, ...sortingCriteria) {
|
|
15720
15561
|
const _range = transposeMatrix(range);
|
|
15721
15562
|
return transposeMatrix(sortMatrix(_range, this.locale, ...sortingCriteria));
|
|
@@ -15734,7 +15575,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15734
15575
|
arg("sort_column (number, range<number>, repeating)", _t("The index of the column in range or a range outside of range containing the values by which to sort.")),
|
|
15735
15576
|
arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
|
|
15736
15577
|
],
|
|
15737
|
-
returns: ["RANGE"],
|
|
15738
15578
|
compute: function (range, n, displayTiesMode, ...sortingCriteria) {
|
|
15739
15579
|
const _n = toNumber(n?.value ?? 1, this.locale);
|
|
15740
15580
|
assert(() => _n >= 0, _t("Wrong value of 'n'. Expected a positive number. Got %s.", _n));
|
|
@@ -15802,7 +15642,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15802
15642
|
arg("by_column (boolean, default=FALSE)", _t("Whether to filter the data by columns or by rows.")),
|
|
15803
15643
|
arg("exactly_once (boolean, default=FALSE)", _t("Whether to return only entries with no duplicates.")),
|
|
15804
15644
|
],
|
|
15805
|
-
returns: ["RANGE<NUMBER>"],
|
|
15806
15645
|
compute: function (range = { value: "" }, byColumn, exactlyOnce) {
|
|
15807
15646
|
if (!isMatrix(range)) {
|
|
15808
15647
|
return [[range]];
|
|
@@ -16027,7 +15866,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16027
15866
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
16028
15867
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16029
15868
|
],
|
|
16030
|
-
returns: ["NUMBER"],
|
|
16031
15869
|
compute: function (issue, maturity, rate, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16032
15870
|
const start = Math.trunc(toNumber(issue, this.locale));
|
|
16033
15871
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16058,7 +15896,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16058
15896
|
arg("rate (number)", _t("The deprecation rate.")),
|
|
16059
15897
|
arg("day_count_convention (number, optional)", _t("An indicator of what day count method to use.")),
|
|
16060
15898
|
],
|
|
16061
|
-
returns: ["NUMBER"],
|
|
16062
15899
|
compute: function (cost, purchaseDate, firstPeriodEnd, salvage, period, rate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16063
15900
|
dayCountConvention = dayCountConvention || 0;
|
|
16064
15901
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -16107,7 +15944,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16107
15944
|
const COUPDAYS = {
|
|
16108
15945
|
description: _t("Days in coupon period containing settlement date."),
|
|
16109
15946
|
args: COUPON_FUNCTION_ARGS,
|
|
16110
|
-
returns: ["NUMBER"],
|
|
16111
15947
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16112
15948
|
dayCountConvention = dayCountConvention || 0;
|
|
16113
15949
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16134,7 +15970,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16134
15970
|
const COUPDAYBS = {
|
|
16135
15971
|
description: _t("Days from settlement until next coupon."),
|
|
16136
15972
|
args: COUPON_FUNCTION_ARGS,
|
|
16137
|
-
returns: ["NUMBER"],
|
|
16138
15973
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16139
15974
|
dayCountConvention = dayCountConvention || 0;
|
|
16140
15975
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16191,7 +16026,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16191
16026
|
const COUPDAYSNC = {
|
|
16192
16027
|
description: _t("Days from settlement until next coupon."),
|
|
16193
16028
|
args: COUPON_FUNCTION_ARGS,
|
|
16194
|
-
returns: ["NUMBER"],
|
|
16195
16029
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16196
16030
|
dayCountConvention = dayCountConvention || 0;
|
|
16197
16031
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16221,7 +16055,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16221
16055
|
const COUPNCD = {
|
|
16222
16056
|
description: _t("Next coupon date after the settlement date."),
|
|
16223
16057
|
args: COUPON_FUNCTION_ARGS,
|
|
16224
|
-
returns: ["NUMBER"],
|
|
16225
16058
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16226
16059
|
dayCountConvention = dayCountConvention || 0;
|
|
16227
16060
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16247,7 +16080,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16247
16080
|
const COUPNUM = {
|
|
16248
16081
|
description: _t("Number of coupons between settlement and maturity."),
|
|
16249
16082
|
args: COUPON_FUNCTION_ARGS,
|
|
16250
|
-
returns: ["NUMBER"],
|
|
16251
16083
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16252
16084
|
dayCountConvention = dayCountConvention || 0;
|
|
16253
16085
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16274,7 +16106,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16274
16106
|
const COUPPCD = {
|
|
16275
16107
|
description: _t("Last coupon date prior to or on the settlement date."),
|
|
16276
16108
|
args: COUPON_FUNCTION_ARGS,
|
|
16277
|
-
returns: ["NUMBER"],
|
|
16278
16109
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16279
16110
|
dayCountConvention = dayCountConvention || 0;
|
|
16280
16111
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16307,7 +16138,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16307
16138
|
arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
|
|
16308
16139
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
16309
16140
|
],
|
|
16310
|
-
returns: ["NUMBER"],
|
|
16311
16141
|
compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16312
16142
|
const first = toNumber(firstPeriod, this.locale);
|
|
16313
16143
|
const last = toNumber(lastPeriod, this.locale);
|
|
@@ -16339,7 +16169,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16339
16169
|
arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
|
|
16340
16170
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
16341
16171
|
],
|
|
16342
|
-
returns: ["NUMBER"],
|
|
16343
16172
|
compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16344
16173
|
const first = toNumber(firstPeriod, this.locale);
|
|
16345
16174
|
const last = toNumber(lastPeriod, this.locale);
|
|
@@ -16370,7 +16199,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16370
16199
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
16371
16200
|
arg("month (number, optional)", _t("The number of months in the first year of depreciation.")),
|
|
16372
16201
|
],
|
|
16373
|
-
returns: ["NUMBER"],
|
|
16374
16202
|
// to do: replace by dollar format
|
|
16375
16203
|
compute: function (cost, salvage, life, period, ...args) {
|
|
16376
16204
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -16439,7 +16267,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16439
16267
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
16440
16268
|
arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The factor by which depreciation decreases.")),
|
|
16441
16269
|
],
|
|
16442
|
-
returns: ["NUMBER"],
|
|
16443
16270
|
compute: function (cost, salvage, life, period, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }) {
|
|
16444
16271
|
const _cost = toNumber(cost, this.locale);
|
|
16445
16272
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -16465,7 +16292,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16465
16292
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
16466
16293
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16467
16294
|
],
|
|
16468
|
-
returns: ["NUMBER"],
|
|
16469
16295
|
compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16470
16296
|
dayCountConvention = dayCountConvention || 0;
|
|
16471
16297
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16501,7 +16327,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16501
16327
|
arg("fractional_price (number)", _t("The price quotation given using fractional decimal conventions.")),
|
|
16502
16328
|
arg("unit (number)", _t("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
|
|
16503
16329
|
],
|
|
16504
|
-
returns: ["NUMBER"],
|
|
16505
16330
|
compute: function (fractionalPrice, unit) {
|
|
16506
16331
|
const price = toNumber(fractionalPrice, this.locale);
|
|
16507
16332
|
const _unit = Math.trunc(toNumber(unit, this.locale));
|
|
@@ -16522,7 +16347,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16522
16347
|
arg("decimal_price (number)", _t("The price quotation given as a decimal value.")),
|
|
16523
16348
|
arg("unit (number)", _t("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
|
|
16524
16349
|
],
|
|
16525
|
-
returns: ["NUMBER"],
|
|
16526
16350
|
compute: function (decimalPrice, unit) {
|
|
16527
16351
|
const price = toNumber(decimalPrice, this.locale);
|
|
16528
16352
|
const _unit = Math.trunc(toNumber(unit, this.locale));
|
|
@@ -16547,7 +16371,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16547
16371
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
16548
16372
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16549
16373
|
],
|
|
16550
|
-
returns: ["NUMBER"],
|
|
16551
16374
|
compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16552
16375
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
16553
16376
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16588,7 +16411,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16588
16411
|
arg("nominal_rate (number)", _t("The nominal interest rate per year.")),
|
|
16589
16412
|
arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
|
|
16590
16413
|
],
|
|
16591
|
-
returns: ["NUMBER"],
|
|
16592
16414
|
compute: function (nominal_rate, periods_per_year) {
|
|
16593
16415
|
const nominal = toNumber(nominal_rate, this.locale);
|
|
16594
16416
|
const periods = Math.trunc(toNumber(periods_per_year, this.locale));
|
|
@@ -16618,7 +16440,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16618
16440
|
arg(`present_value (number, default=${DEFAULT_PRESENT_VALUE})`, _t("The current value of the annuity.")),
|
|
16619
16441
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
16620
16442
|
],
|
|
16621
|
-
returns: ["NUMBER"],
|
|
16622
16443
|
// to do: replace by dollar format
|
|
16623
16444
|
compute: function (rate, numberOfPeriods, paymentAmount, presentValue = { value: DEFAULT_PRESENT_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16624
16445
|
presentValue = presentValue || 0;
|
|
@@ -16644,7 +16465,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16644
16465
|
arg("principal (number)", _t("The amount of initial capital or value to compound against.")),
|
|
16645
16466
|
arg("rate_schedule (number, range<number>)", _t("A series of interest rates to compound against the principal.")),
|
|
16646
16467
|
],
|
|
16647
|
-
returns: ["NUMBER"],
|
|
16648
16468
|
compute: function (principalAmount, rateSchedule) {
|
|
16649
16469
|
const principal = toNumber(principalAmount, this.locale);
|
|
16650
16470
|
return reduceAny([rateSchedule], (acc, rate) => acc * (1 + toNumber(rate, this.locale)), principal);
|
|
@@ -16663,7 +16483,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16663
16483
|
arg("redemption (number)", _t("The amount to be received at maturity.")),
|
|
16664
16484
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16665
16485
|
],
|
|
16666
|
-
returns: ["NUMBER"],
|
|
16667
16486
|
compute: function (settlement, maturity, investment, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16668
16487
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
16669
16488
|
const _maturity = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16702,7 +16521,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16702
16521
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
16703
16522
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
16704
16523
|
],
|
|
16705
|
-
returns: ["NUMBER"],
|
|
16706
16524
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16707
16525
|
const r = toNumber(rate, this.locale);
|
|
16708
16526
|
const period = toNumber(currentPeriod, this.locale);
|
|
@@ -16727,7 +16545,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16727
16545
|
arg("cashflow_amounts (number, range<number>)", _t("An array or range containing the income or payments associated with the investment.")),
|
|
16728
16546
|
arg(`rate_guess (number, default=${DEFAULT_RATE_GUESS})`, _t("An estimate for what the internal rate of return will be.")),
|
|
16729
16547
|
],
|
|
16730
|
-
returns: ["NUMBER"],
|
|
16731
16548
|
compute: function (cashFlowAmounts, rateGuess = { value: DEFAULT_RATE_GUESS }) {
|
|
16732
16549
|
const _rateGuess = toNumber(rateGuess, this.locale);
|
|
16733
16550
|
assertRateGuessStrictlyGreaterThanMinusOne(_rateGuess);
|
|
@@ -16789,7 +16606,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16789
16606
|
arg("number_of_periods (number)", _t("The number of payments to be made.")),
|
|
16790
16607
|
arg("present_value (number)", _t("The current value of the annuity.")),
|
|
16791
16608
|
],
|
|
16792
|
-
returns: ["NUMBER"],
|
|
16793
16609
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue) {
|
|
16794
16610
|
const interestRate = toNumber(rate, this.locale);
|
|
16795
16611
|
const period = toNumber(currentPeriod, this.locale);
|
|
@@ -16814,7 +16630,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16814
16630
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
16815
16631
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16816
16632
|
],
|
|
16817
|
-
returns: ["NUMBER"],
|
|
16818
16633
|
compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16819
16634
|
const duration = DURATION.compute.bind(this)(settlement, maturity, rate, securityYield, frequency, dayCountConvention);
|
|
16820
16635
|
const y = toNumber(securityYield, this.locale);
|
|
@@ -16833,7 +16648,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16833
16648
|
arg("financing_rate (number)", _t("The interest rate paid on funds invested.")),
|
|
16834
16649
|
arg("reinvestment_return_rate (number)", _t("The return (as a percentage) earned on reinvestment of income received from the investment.")),
|
|
16835
16650
|
],
|
|
16836
|
-
returns: ["NUMBER"],
|
|
16837
16651
|
compute: function (cashflowAmount, financingRate, reinvestmentRate) {
|
|
16838
16652
|
const fRate = toNumber(financingRate, this.locale);
|
|
16839
16653
|
const rRate = toNumber(reinvestmentRate, this.locale);
|
|
@@ -16885,7 +16699,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16885
16699
|
arg("effective_rate (number)", _t("The effective interest rate per year.")),
|
|
16886
16700
|
arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
|
|
16887
16701
|
],
|
|
16888
|
-
returns: ["NUMBER"],
|
|
16889
16702
|
compute: function (effective_rate, periods_per_year) {
|
|
16890
16703
|
const effective = toNumber(effective_rate, this.locale);
|
|
16891
16704
|
const periods = Math.trunc(toNumber(periods_per_year, this.locale));
|
|
@@ -16908,7 +16721,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16908
16721
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
16909
16722
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
16910
16723
|
],
|
|
16911
|
-
returns: ["NUMBER"],
|
|
16912
16724
|
compute: function (rate, paymentAmount, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16913
16725
|
futureValue = futureValue || 0;
|
|
16914
16726
|
endOrBeginning = endOrBeginning || 0;
|
|
@@ -16956,7 +16768,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16956
16768
|
arg("cashflow1 (number, range<number>)", _t("The first future cash flow.")),
|
|
16957
16769
|
arg("cashflow2 (number, range<number>, repeating)", _t("Additional future cash flows.")),
|
|
16958
16770
|
],
|
|
16959
|
-
returns: ["NUMBER"],
|
|
16960
16771
|
// to do: replace by dollar format
|
|
16961
16772
|
compute: function (discount, ...values) {
|
|
16962
16773
|
const _discount = toNumber(discount, this.locale);
|
|
@@ -16978,7 +16789,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16978
16789
|
arg("present_value (number)", _t("The investment's current value.")),
|
|
16979
16790
|
arg("future_value (number)", _t("The investment's desired future value.")),
|
|
16980
16791
|
],
|
|
16981
|
-
returns: ["NUMBER"],
|
|
16982
16792
|
compute: function (rate, presentValue, futureValue) {
|
|
16983
16793
|
const _rate = toNumber(rate, this.locale);
|
|
16984
16794
|
const _presentValue = toNumber(presentValue, this.locale);
|
|
@@ -17018,7 +16828,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17018
16828
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17019
16829
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
17020
16830
|
],
|
|
17021
|
-
returns: ["NUMBER"],
|
|
17022
16831
|
compute: function (rate, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17023
16832
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17024
16833
|
const r = toNumber(rate, this.locale);
|
|
@@ -17054,7 +16863,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17054
16863
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17055
16864
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
17056
16865
|
],
|
|
17057
|
-
returns: ["NUMBER"],
|
|
17058
16866
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17059
16867
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17060
16868
|
const r = toNumber(rate, this.locale);
|
|
@@ -17081,7 +16889,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17081
16889
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17082
16890
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
17083
16891
|
],
|
|
17084
|
-
returns: ["NUMBER"],
|
|
17085
16892
|
// to do: replace by dollar format
|
|
17086
16893
|
compute: function (rate, numberOfPeriods, paymentAmount, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17087
16894
|
futureValue = futureValue || 0;
|
|
@@ -17115,7 +16922,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17115
16922
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
17116
16923
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17117
16924
|
],
|
|
17118
|
-
returns: ["NUMBER"],
|
|
17119
16925
|
compute: function (settlement, maturity, rate, securityYield, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17120
16926
|
dayCountConvention = dayCountConvention || 0;
|
|
17121
16927
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17163,7 +16969,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17163
16969
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
17164
16970
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17165
16971
|
],
|
|
17166
|
-
returns: ["NUMBER"],
|
|
17167
16972
|
compute: function (settlement, maturity, discount, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17168
16973
|
dayCountConvention = dayCountConvention || 0;
|
|
17169
16974
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17201,7 +17006,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17201
17006
|
arg("yield (number)", _t("The expected annual yield of the security.")),
|
|
17202
17007
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17203
17008
|
],
|
|
17204
|
-
returns: ["NUMBER"],
|
|
17205
17009
|
compute: function (settlement, maturity, issue, rate, securityYield, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17206
17010
|
dayCountConvention = dayCountConvention || 0;
|
|
17207
17011
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17265,7 +17069,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17265
17069
|
arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
|
|
17266
17070
|
arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the interest rate will be.")),
|
|
17267
17071
|
],
|
|
17268
|
-
returns: ["NUMBER"],
|
|
17269
17072
|
compute: function (numberOfPeriods, paymentPerPeriod, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }, rateGuess = { value: RATE_GUESS_DEFAULT }) {
|
|
17270
17073
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17271
17074
|
const payment = toNumber(paymentPerPeriod, this.locale);
|
|
@@ -17311,7 +17114,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17311
17114
|
arg("discount (number)", _t("The discount rate of the security invested in.")),
|
|
17312
17115
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17313
17116
|
],
|
|
17314
|
-
returns: ["NUMBER"],
|
|
17315
17117
|
compute: function (settlement, maturity, investment, discount, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17316
17118
|
dayCountConvention = dayCountConvention || 0;
|
|
17317
17119
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17349,7 +17151,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17349
17151
|
arg("present_value (number)", _t("The present value of the investment.")),
|
|
17350
17152
|
arg("future_value (number)", _t("The future value of the investment.")),
|
|
17351
17153
|
],
|
|
17352
|
-
returns: ["NUMBER"],
|
|
17353
17154
|
compute: function (numberOfPeriods, presentValue, futureValue) {
|
|
17354
17155
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17355
17156
|
const pv = toNumber(presentValue, this.locale);
|
|
@@ -17374,7 +17175,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17374
17175
|
arg("salvage (number)", _t("The value of the asset at the end of depreciation.")),
|
|
17375
17176
|
arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
|
|
17376
17177
|
],
|
|
17377
|
-
returns: ["NUMBER"],
|
|
17378
17178
|
compute: function (cost, salvage, life) {
|
|
17379
17179
|
const _cost = toNumber(cost, this.locale);
|
|
17380
17180
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -17399,7 +17199,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17399
17199
|
arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
|
|
17400
17200
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
17401
17201
|
],
|
|
17402
|
-
returns: ["NUMBER"],
|
|
17403
17202
|
compute: function (cost, salvage, life, period) {
|
|
17404
17203
|
const _cost = toNumber(cost, this.locale);
|
|
17405
17204
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -17448,7 +17247,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17448
17247
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17449
17248
|
arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
|
|
17450
17249
|
],
|
|
17451
|
-
returns: ["NUMBER"],
|
|
17452
17250
|
compute: function (settlement, maturity, discount) {
|
|
17453
17251
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17454
17252
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17471,7 +17269,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17471
17269
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17472
17270
|
arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
|
|
17473
17271
|
],
|
|
17474
|
-
returns: ["NUMBER"],
|
|
17475
17272
|
compute: function (settlement, maturity, discount) {
|
|
17476
17273
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17477
17274
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17529,7 +17326,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17529
17326
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17530
17327
|
arg("price (number)", _t("The price at which the security is bought per 100 face value.")),
|
|
17531
17328
|
],
|
|
17532
|
-
returns: ["NUMBER"],
|
|
17533
17329
|
compute: function (settlement, maturity, price) {
|
|
17534
17330
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17535
17331
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17569,7 +17365,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17569
17365
|
arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The number of months in the first year of depreciation.")),
|
|
17570
17366
|
arg(`no_switch (number, default=${DEFAULT_VDB_NO_SWITCH})`, _t("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")),
|
|
17571
17367
|
],
|
|
17572
|
-
returns: ["NUMBER"],
|
|
17573
17368
|
compute: function (cost, salvage, life, startPeriod, endPeriod, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }, noSwitch = { value: DEFAULT_VDB_NO_SWITCH }) {
|
|
17574
17369
|
factor = factor || 0;
|
|
17575
17370
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -17634,7 +17429,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17634
17429
|
arg("cashflow_dates (range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
|
|
17635
17430
|
arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the internal rate of return will be.")),
|
|
17636
17431
|
],
|
|
17637
|
-
returns: ["NUMBER"],
|
|
17638
17432
|
compute: function (cashflowAmounts, cashflowDates, rateGuess = { value: RATE_GUESS_DEFAULT }) {
|
|
17639
17433
|
const guess = toNumber(rateGuess, this.locale);
|
|
17640
17434
|
const _cashFlows = cashflowAmounts.flat().map((val) => toNumber(val, this.locale));
|
|
@@ -17705,7 +17499,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17705
17499
|
arg("cashflow_amounts (number, range<number>)", _t("An range containing the income or payments associated with the investment.")),
|
|
17706
17500
|
arg("cashflow_dates (number, range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
|
|
17707
17501
|
],
|
|
17708
|
-
returns: ["NUMBER"],
|
|
17709
17502
|
compute: function (discount, cashflowAmounts, cashflowDates) {
|
|
17710
17503
|
const rate = toNumber(discount, this.locale);
|
|
17711
17504
|
const _cashFlows = isMatrix(cashflowAmounts)
|
|
@@ -17772,7 +17565,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17772
17565
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
17773
17566
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17774
17567
|
],
|
|
17775
|
-
returns: ["NUMBER"],
|
|
17776
17568
|
compute: function (settlement, maturity, rate, price, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17777
17569
|
dayCountConvention = dayCountConvention || 0;
|
|
17778
17570
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17847,7 +17639,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17847
17639
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
17848
17640
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17849
17641
|
],
|
|
17850
|
-
returns: ["NUMBER"],
|
|
17851
17642
|
compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17852
17643
|
dayCountConvention = dayCountConvention || 0;
|
|
17853
17644
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17884,7 +17675,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17884
17675
|
arg("price (number)", _t("The price at which the security is bought.")),
|
|
17885
17676
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17886
17677
|
],
|
|
17887
|
-
returns: ["NUMBER"],
|
|
17888
17678
|
compute: function (settlement, maturity, issue, rate, price, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17889
17679
|
dayCountConvention = dayCountConvention || 0;
|
|
17890
17680
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17971,7 +17761,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17971
17761
|
arg("info_type (string)", _t("The type of information requested. Can be one of %s", CELL_INFO_TYPES.join(", "))),
|
|
17972
17762
|
arg("reference (meta)", _t("The reference to the cell.")),
|
|
17973
17763
|
],
|
|
17974
|
-
returns: ["ANY"],
|
|
17975
17764
|
compute: function (info, reference) {
|
|
17976
17765
|
const _info = toString(info).toLowerCase();
|
|
17977
17766
|
assert(() => CELL_INFO_TYPES.includes(_info), _t("The info_type should be one of %s.", CELL_INFO_TYPES.join(", ")));
|
|
@@ -18022,7 +17811,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18022
17811
|
const ISERR = {
|
|
18023
17812
|
description: _t("Whether a value is an error other than #N/A."),
|
|
18024
17813
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18025
|
-
returns: ["BOOLEAN"],
|
|
18026
17814
|
compute: function (data) {
|
|
18027
17815
|
const value = data?.value;
|
|
18028
17816
|
return isEvaluationError(value) && value !== CellErrorType.NotAvailable;
|
|
@@ -18035,7 +17823,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18035
17823
|
const ISERROR = {
|
|
18036
17824
|
description: _t("Whether a value is an error."),
|
|
18037
17825
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18038
|
-
returns: ["BOOLEAN"],
|
|
18039
17826
|
compute: function (data) {
|
|
18040
17827
|
const value = data?.value;
|
|
18041
17828
|
return isEvaluationError(value);
|
|
@@ -18048,7 +17835,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18048
17835
|
const ISLOGICAL = {
|
|
18049
17836
|
description: _t("Whether a value is `true` or `false`."),
|
|
18050
17837
|
args: [arg("value (any)", _t("The value to be verified as a logical TRUE or FALSE."))],
|
|
18051
|
-
returns: ["BOOLEAN"],
|
|
18052
17838
|
compute: function (value) {
|
|
18053
17839
|
return typeof value?.value === "boolean";
|
|
18054
17840
|
},
|
|
@@ -18060,7 +17846,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18060
17846
|
const ISNA = {
|
|
18061
17847
|
description: _t("Whether a value is the error #N/A."),
|
|
18062
17848
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18063
|
-
returns: ["BOOLEAN"],
|
|
18064
17849
|
compute: function (data) {
|
|
18065
17850
|
return data?.value === CellErrorType.NotAvailable;
|
|
18066
17851
|
},
|
|
@@ -18072,7 +17857,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18072
17857
|
const ISNONTEXT = {
|
|
18073
17858
|
description: _t("Whether a value is non-textual."),
|
|
18074
17859
|
args: [arg("value (any)", _t("The value to be checked."))],
|
|
18075
|
-
returns: ["BOOLEAN"],
|
|
18076
17860
|
compute: function (value) {
|
|
18077
17861
|
return !ISTEXT.compute.bind(this)(value);
|
|
18078
17862
|
},
|
|
@@ -18084,7 +17868,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18084
17868
|
const ISNUMBER = {
|
|
18085
17869
|
description: _t("Whether a value is a number."),
|
|
18086
17870
|
args: [arg("value (any)", _t("The value to be verified as a number."))],
|
|
18087
|
-
returns: ["BOOLEAN"],
|
|
18088
17871
|
compute: function (value) {
|
|
18089
17872
|
return typeof value?.value === "number";
|
|
18090
17873
|
},
|
|
@@ -18096,7 +17879,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18096
17879
|
const ISTEXT = {
|
|
18097
17880
|
description: _t("Whether a value is text."),
|
|
18098
17881
|
args: [arg("value (any)", _t("The value to be verified as text."))],
|
|
18099
|
-
returns: ["BOOLEAN"],
|
|
18100
17882
|
compute: function (value) {
|
|
18101
17883
|
return typeof value?.value === "string" && isEvaluationError(value?.value) === false;
|
|
18102
17884
|
},
|
|
@@ -18108,7 +17890,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18108
17890
|
const ISBLANK = {
|
|
18109
17891
|
description: _t("Whether the referenced cell is empty"),
|
|
18110
17892
|
args: [arg("value (any)", _t("Reference to the cell that will be checked for emptiness."))],
|
|
18111
|
-
returns: ["BOOLEAN"],
|
|
18112
17893
|
compute: function (value) {
|
|
18113
17894
|
return value?.value === null;
|
|
18114
17895
|
},
|
|
@@ -18120,7 +17901,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18120
17901
|
const NA = {
|
|
18121
17902
|
description: _t("Returns the error value #N/A."),
|
|
18122
17903
|
args: [],
|
|
18123
|
-
returns: ["BOOLEAN"],
|
|
18124
17904
|
compute: function () {
|
|
18125
17905
|
return { value: CellErrorType.NotAvailable };
|
|
18126
17906
|
},
|
|
@@ -18177,7 +17957,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18177
17957
|
arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
|
|
18178
17958
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that represent logical values.")),
|
|
18179
17959
|
],
|
|
18180
|
-
returns: ["BOOLEAN"],
|
|
18181
17960
|
compute: function (...logicalExpressions) {
|
|
18182
17961
|
const { result, foundBoolean } = boolAnd(logicalExpressions);
|
|
18183
17962
|
assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
|
|
@@ -18191,7 +17970,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18191
17970
|
const FALSE = {
|
|
18192
17971
|
description: _t("Logical value `false`."),
|
|
18193
17972
|
args: [],
|
|
18194
|
-
returns: ["BOOLEAN"],
|
|
18195
17973
|
compute: function () {
|
|
18196
17974
|
return false;
|
|
18197
17975
|
},
|
|
@@ -18207,7 +17985,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18207
17985
|
arg("value_if_true (any)", _t("The value the function returns if logical_expression is TRUE.")),
|
|
18208
17986
|
arg("value_if_false (any, default=FALSE)", _t("The value the function returns if logical_expression is FALSE.")),
|
|
18209
17987
|
],
|
|
18210
|
-
returns: ["ANY"],
|
|
18211
17988
|
compute: function (logicalExpression, valueIfTrue, valueIfFalse) {
|
|
18212
17989
|
const result = toBoolean(logicalExpression?.value) ? valueIfTrue : valueIfFalse;
|
|
18213
17990
|
if (result === undefined) {
|
|
@@ -18229,7 +18006,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18229
18006
|
arg("value (any)", _t("The value to return if value itself is not an error.")),
|
|
18230
18007
|
arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an error.")),
|
|
18231
18008
|
],
|
|
18232
|
-
returns: ["ANY"],
|
|
18233
18009
|
compute: function (value, valueIfError = { value: "" }) {
|
|
18234
18010
|
const result = isEvaluationError(value?.value) ? valueIfError : value;
|
|
18235
18011
|
if (result === undefined) {
|
|
@@ -18251,7 +18027,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18251
18027
|
arg("value (any)", _t("The value to return if value itself is not #N/A an error.")),
|
|
18252
18028
|
arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an #N/A error.")),
|
|
18253
18029
|
],
|
|
18254
|
-
returns: ["ANY"],
|
|
18255
18030
|
compute: function (value, valueIfError = { value: "" }) {
|
|
18256
18031
|
const result = value?.value === CellErrorType.NotAvailable ? valueIfError : value;
|
|
18257
18032
|
if (result === undefined) {
|
|
@@ -18275,7 +18050,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18275
18050
|
arg("condition2 (boolean, repeating)", _t("Additional conditions to be evaluated if the previous ones are FALSE.")),
|
|
18276
18051
|
arg("value2 (any, repeating)", _t("Additional values to be returned if their corresponding conditions are TRUE.")),
|
|
18277
18052
|
],
|
|
18278
|
-
returns: ["ANY"],
|
|
18279
18053
|
compute: function (...values) {
|
|
18280
18054
|
assert(() => values.length % 2 === 0, _t("Wrong number of arguments. Expected an even number of arguments."));
|
|
18281
18055
|
for (let n = 0; n < values.length - 1; n += 2) {
|
|
@@ -18302,7 +18076,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18302
18076
|
args: [
|
|
18303
18077
|
arg("logical_expression (boolean)", _t("An expression or reference to a cell holding an expression that represents some logical value.")),
|
|
18304
18078
|
],
|
|
18305
|
-
returns: ["BOOLEAN"],
|
|
18306
18079
|
compute: function (logicalExpression) {
|
|
18307
18080
|
return !toBoolean(logicalExpression);
|
|
18308
18081
|
},
|
|
@@ -18317,7 +18090,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18317
18090
|
arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
|
|
18318
18091
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
|
|
18319
18092
|
],
|
|
18320
|
-
returns: ["BOOLEAN"],
|
|
18321
18093
|
compute: function (...logicalExpressions) {
|
|
18322
18094
|
const { result, foundBoolean } = boolOr(logicalExpressions);
|
|
18323
18095
|
assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
|
|
@@ -18331,7 +18103,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18331
18103
|
const TRUE = {
|
|
18332
18104
|
description: _t("Logical value `true`."),
|
|
18333
18105
|
args: [],
|
|
18334
|
-
returns: ["BOOLEAN"],
|
|
18335
18106
|
compute: function () {
|
|
18336
18107
|
return true;
|
|
18337
18108
|
},
|
|
@@ -18346,7 +18117,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18346
18117
|
arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
|
|
18347
18118
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
|
|
18348
18119
|
],
|
|
18349
|
-
returns: ["BOOLEAN"],
|
|
18350
18120
|
compute: function (...logicalExpressions) {
|
|
18351
18121
|
let foundBoolean = false;
|
|
18352
18122
|
let acc = false;
|
|
@@ -18375,9 +18145,229 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18375
18145
|
XOR: XOR
|
|
18376
18146
|
});
|
|
18377
18147
|
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18148
|
+
const pivotTimeAdapterRegistry = new Registry();
|
|
18149
|
+
function pivotTimeAdapter(granularity) {
|
|
18150
|
+
return pivotTimeAdapterRegistry.get(granularity);
|
|
18151
|
+
}
|
|
18152
|
+
/**
|
|
18153
|
+
* The Time Adapter: Managing Time Periods for Pivot Functions
|
|
18154
|
+
*
|
|
18155
|
+
* Overview:
|
|
18156
|
+
* A time adapter is responsible for managing time periods associated with pivot functions.
|
|
18157
|
+
* Each type of period (day, week, month, quarter, etc.) has its own dedicated adapter.
|
|
18158
|
+
* The adapter's primary role is to normalize period values between spreadsheet functions,
|
|
18159
|
+
* and the pivot.
|
|
18160
|
+
* By normalizing the period value, it can be stored consistently in the pivot.
|
|
18161
|
+
*
|
|
18162
|
+
* Normalization Process:
|
|
18163
|
+
* When working with functions in the spreadsheet, the time adapter normalizes
|
|
18164
|
+
* the provided period to facilitate accurate lookup of values in the pivot.
|
|
18165
|
+
* For instance, if the spreadsheet function represents a day period as a number generated
|
|
18166
|
+
* by the DATE function (DATE(2023, 12, 25)), the time adapter will normalize it accordingly.
|
|
18167
|
+
*
|
|
18168
|
+
*/
|
|
18169
|
+
/**
|
|
18170
|
+
* Normalized value: "12/25/2023"
|
|
18171
|
+
*
|
|
18172
|
+
* Note: Those two format are equivalent:
|
|
18173
|
+
* - "MM/dd/yyyy" (luxon format)
|
|
18174
|
+
* - "mm/dd/yyyy" (spreadsheet format)
|
|
18175
|
+
**/
|
|
18176
|
+
const dayAdapter = {
|
|
18177
|
+
normalizeFunctionValue(value) {
|
|
18178
|
+
const date = toNumber(value, DEFAULT_LOCALE);
|
|
18179
|
+
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/dd/yyyy" });
|
|
18180
|
+
},
|
|
18181
|
+
getFormat(locale) {
|
|
18182
|
+
return (locale ?? DEFAULT_LOCALE).dateFormat;
|
|
18183
|
+
},
|
|
18184
|
+
formatValue(normalizedValue, locale) {
|
|
18185
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18186
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18187
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18188
|
+
},
|
|
18189
|
+
toCellValue(normalizedValue) {
|
|
18190
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18191
|
+
},
|
|
18192
|
+
};
|
|
18193
|
+
/**
|
|
18194
|
+
* normalizes day of month number
|
|
18195
|
+
*/
|
|
18196
|
+
const dayOfMonthAdapter = {
|
|
18197
|
+
normalizeFunctionValue(value) {
|
|
18198
|
+
const day = toNumber(value, DEFAULT_LOCALE);
|
|
18199
|
+
if (day < 1 || day > 31) {
|
|
18200
|
+
throw new EvaluationError(_t("%s is not a valid day of month (it should be a number between 1 and 31)", day));
|
|
18201
|
+
}
|
|
18202
|
+
return day;
|
|
18203
|
+
},
|
|
18204
|
+
getFormat() {
|
|
18205
|
+
return "0";
|
|
18206
|
+
},
|
|
18207
|
+
formatValue(normalizedValue, locale) {
|
|
18208
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18209
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18210
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18211
|
+
},
|
|
18212
|
+
toCellValue(normalizedValue) {
|
|
18213
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18214
|
+
},
|
|
18215
|
+
};
|
|
18216
|
+
/**
|
|
18217
|
+
* Normalized value: "2/2023" for week 2 of 2023
|
|
18218
|
+
*/
|
|
18219
|
+
const weekAdapter = {
|
|
18220
|
+
normalizeFunctionValue(value) {
|
|
18221
|
+
const [week, year] = value.split("/");
|
|
18222
|
+
return `${Number(week)}/${Number(year)}`;
|
|
18223
|
+
},
|
|
18224
|
+
getFormat() {
|
|
18225
|
+
return undefined;
|
|
18226
|
+
},
|
|
18227
|
+
formatValue(normalizedValue) {
|
|
18228
|
+
const [week, year] = normalizedValue.split("/");
|
|
18229
|
+
return _t("W%(week)s %(year)s", { week, year });
|
|
18230
|
+
},
|
|
18231
|
+
toCellValue(normalizedValue) {
|
|
18232
|
+
return this.formatValue(normalizedValue);
|
|
18233
|
+
},
|
|
18234
|
+
};
|
|
18235
|
+
/**
|
|
18236
|
+
* normalizes iso week number
|
|
18237
|
+
*/
|
|
18238
|
+
const isoWeekNumberAdapter = {
|
|
18239
|
+
normalizeFunctionValue(value) {
|
|
18240
|
+
const isoWeek = toNumber(value, DEFAULT_LOCALE);
|
|
18241
|
+
if (isoWeek < 0 || isoWeek > 53) {
|
|
18242
|
+
throw new EvaluationError(_t("%s is not a valid week (it should be a number between 0 and 53)", isoWeek));
|
|
18243
|
+
}
|
|
18244
|
+
return isoWeek;
|
|
18245
|
+
},
|
|
18246
|
+
getFormat() {
|
|
18247
|
+
return "0";
|
|
18248
|
+
},
|
|
18249
|
+
formatValue(normalizedValue, locale) {
|
|
18250
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18251
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18252
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18253
|
+
},
|
|
18254
|
+
toCellValue(normalizedValue) {
|
|
18255
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18256
|
+
},
|
|
18257
|
+
};
|
|
18258
|
+
/**
|
|
18259
|
+
* normalized month value is a string formatted as "MM/yyyy" (luxon format)
|
|
18260
|
+
* e.g. "01/2020" for January 2020
|
|
18261
|
+
*/
|
|
18262
|
+
const monthAdapter = {
|
|
18263
|
+
normalizeFunctionValue(value) {
|
|
18264
|
+
const date = toNumber(value, DEFAULT_LOCALE);
|
|
18265
|
+
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
|
|
18266
|
+
},
|
|
18267
|
+
getFormat() {
|
|
18268
|
+
return "mmmm yyyy";
|
|
18269
|
+
},
|
|
18270
|
+
formatValue(normalizedValue, locale) {
|
|
18271
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18272
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18273
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18274
|
+
},
|
|
18275
|
+
toCellValue(normalizedValue) {
|
|
18276
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18277
|
+
},
|
|
18278
|
+
};
|
|
18279
|
+
/**
|
|
18280
|
+
* normalizes month number
|
|
18281
|
+
*/
|
|
18282
|
+
const monthNumberAdapter = {
|
|
18283
|
+
normalizeFunctionValue(value) {
|
|
18284
|
+
const month = toNumber(value, DEFAULT_LOCALE);
|
|
18285
|
+
if (month < 1 || month > 12) {
|
|
18286
|
+
throw new EvaluationError(_t("%s is not a valid month (it should be a number between 1 and 12)", month));
|
|
18287
|
+
}
|
|
18288
|
+
return month;
|
|
18289
|
+
},
|
|
18290
|
+
getFormat() {
|
|
18291
|
+
return "0";
|
|
18292
|
+
},
|
|
18293
|
+
formatValue(normalizedValue, locale) {
|
|
18294
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18295
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18296
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18297
|
+
},
|
|
18298
|
+
toCellValue(normalizedValue) {
|
|
18299
|
+
return MONTHS[toNumber(normalizedValue, DEFAULT_LOCALE) - 1].toString();
|
|
18300
|
+
},
|
|
18301
|
+
};
|
|
18302
|
+
/**
|
|
18303
|
+
* normalized quarter value is "quarter/year"
|
|
18304
|
+
* e.g. "1/2020" for Q1 2020
|
|
18305
|
+
*/
|
|
18306
|
+
const quarterAdapter = {
|
|
18307
|
+
normalizeFunctionValue(value) {
|
|
18308
|
+
const [quarter, year] = value.split("/");
|
|
18309
|
+
return `${quarter}/${year}`;
|
|
18310
|
+
},
|
|
18311
|
+
getFormat() {
|
|
18312
|
+
return undefined;
|
|
18313
|
+
},
|
|
18314
|
+
formatValue(normalizedValue) {
|
|
18315
|
+
const [quarter, year] = normalizedValue.split("/");
|
|
18316
|
+
return _t("Q%(quarter)s %(year)s", { quarter, year });
|
|
18317
|
+
},
|
|
18318
|
+
toCellValue(normalizedValue) {
|
|
18319
|
+
return this.formatValue(normalizedValue);
|
|
18320
|
+
},
|
|
18321
|
+
};
|
|
18322
|
+
/**
|
|
18323
|
+
* normalizes quarter number
|
|
18324
|
+
*/
|
|
18325
|
+
const quarterNumberAdapter = {
|
|
18326
|
+
normalizeFunctionValue(value) {
|
|
18327
|
+
const quarter = toNumber(value, DEFAULT_LOCALE);
|
|
18328
|
+
if (quarter < 1 || quarter > 4) {
|
|
18329
|
+
throw new EvaluationError(_t("%s is not a valid quarter (it should be a number between 1 and 4)", quarter));
|
|
18330
|
+
}
|
|
18331
|
+
return quarter;
|
|
18332
|
+
},
|
|
18333
|
+
getFormat() {
|
|
18334
|
+
return "0";
|
|
18335
|
+
},
|
|
18336
|
+
formatValue(normalizedValue, locale) {
|
|
18337
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18338
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18339
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18340
|
+
},
|
|
18341
|
+
toCellValue(normalizedValue) {
|
|
18342
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18343
|
+
},
|
|
18344
|
+
};
|
|
18345
|
+
const yearAdapter = {
|
|
18346
|
+
normalizeFunctionValue(value) {
|
|
18347
|
+
return toNumber(value, DEFAULT_LOCALE);
|
|
18348
|
+
},
|
|
18349
|
+
getFormat() {
|
|
18350
|
+
return "0";
|
|
18351
|
+
},
|
|
18352
|
+
formatValue(normalizedValue, locale) {
|
|
18353
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18354
|
+
return formatValue(normalizedValue, { locale, format: "0" });
|
|
18355
|
+
},
|
|
18356
|
+
toCellValue(normalizedValue) {
|
|
18357
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18358
|
+
},
|
|
18359
|
+
};
|
|
18360
|
+
pivotTimeAdapterRegistry
|
|
18361
|
+
.add("day", dayAdapter)
|
|
18362
|
+
.add("week", weekAdapter)
|
|
18363
|
+
.add("month", monthAdapter)
|
|
18364
|
+
.add("quarter", quarterAdapter)
|
|
18365
|
+
.add("year", yearAdapter)
|
|
18366
|
+
.add("day_of_month", dayOfMonthAdapter)
|
|
18367
|
+
.add("iso_week_number", isoWeekNumberAdapter)
|
|
18368
|
+
.add("month_number", monthNumberAdapter)
|
|
18369
|
+
.add("quarter_number", quarterNumberAdapter)
|
|
18370
|
+
.add("year_number", yearAdapter);
|
|
18381
18371
|
|
|
18382
18372
|
const AGGREGATOR_NAMES = {
|
|
18383
18373
|
count: _t("Count"),
|
|
@@ -18393,7 +18383,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18393
18383
|
const AGGREGATORS_BY_FIELD_TYPE = {
|
|
18394
18384
|
integer: NUMBER_CHAR_AGGREGATORS,
|
|
18395
18385
|
char: NUMBER_CHAR_AGGREGATORS,
|
|
18396
|
-
|
|
18386
|
+
boolean: ["count_distinct", "count", "bool_and", "bool_or"],
|
|
18397
18387
|
};
|
|
18398
18388
|
const AGGREGATORS = {};
|
|
18399
18389
|
for (const type in AGGREGATORS_BY_FIELD_TYPE) {
|
|
@@ -18503,6 +18493,44 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18503
18493
|
function flatPivotDomain(domain) {
|
|
18504
18494
|
return domain.flatMap((arg) => [arg.field, arg.value]);
|
|
18505
18495
|
}
|
|
18496
|
+
/**
|
|
18497
|
+
* Parses the value defining a pivot group in a PIVOT formula
|
|
18498
|
+
* e.g. given the following formula PIVOT.VALUE("1", "stage_id", "42", "status", "won"),
|
|
18499
|
+
* the two group values are "42" and "won".
|
|
18500
|
+
*/
|
|
18501
|
+
function toNormalizedPivotValue(dimension, groupValue) {
|
|
18502
|
+
if (groupValue === null || groupValue === "null") {
|
|
18503
|
+
return null;
|
|
18504
|
+
}
|
|
18505
|
+
const groupValueString = typeof groupValue === "boolean"
|
|
18506
|
+
? toString(groupValue).toLocaleLowerCase()
|
|
18507
|
+
: toString(groupValue);
|
|
18508
|
+
if (!pivotNormalizationValueRegistry.contains(dimension.type)) {
|
|
18509
|
+
throw new EvaluationError(_t("Field %(field)s is not supported because of its type (%(type)s)", {
|
|
18510
|
+
field: dimension.displayName,
|
|
18511
|
+
type: dimension.type,
|
|
18512
|
+
}));
|
|
18513
|
+
}
|
|
18514
|
+
// represents a field which is not set (=False server side)
|
|
18515
|
+
if (groupValueString === "false") {
|
|
18516
|
+
return false;
|
|
18517
|
+
}
|
|
18518
|
+
const normalizer = pivotNormalizationValueRegistry.get(dimension.type);
|
|
18519
|
+
return normalizer(groupValueString, dimension.granularity);
|
|
18520
|
+
}
|
|
18521
|
+
function normalizeDateTime(value, granularity) {
|
|
18522
|
+
if (!granularity) {
|
|
18523
|
+
throw "";
|
|
18524
|
+
}
|
|
18525
|
+
return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
|
|
18526
|
+
}
|
|
18527
|
+
const pivotNormalizationValueRegistry = new Registry();
|
|
18528
|
+
pivotNormalizationValueRegistry
|
|
18529
|
+
.add("date", normalizeDateTime)
|
|
18530
|
+
.add("datetime", normalizeDateTime)
|
|
18531
|
+
.add("integer", (value) => toNumber(value, DEFAULT_LOCALE))
|
|
18532
|
+
.add("boolean", (value) => toBoolean(value))
|
|
18533
|
+
.add("char", (value) => toString(value));
|
|
18506
18534
|
|
|
18507
18535
|
/**
|
|
18508
18536
|
* Get the pivot ID from the formula pivot ID.
|
|
@@ -18579,7 +18607,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18579
18607
|
arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
|
|
18580
18608
|
arg("sheet (string, optional)", _t("A string indicating the name of the sheet into which the address points.")),
|
|
18581
18609
|
],
|
|
18582
|
-
returns: ["STRING"],
|
|
18583
18610
|
compute: function (row, column, absoluteRelativeMode = { value: DEFAULT_ABSOLUTE_RELATIVE_MODE }, useA1Notation = { value: true }, sheet) {
|
|
18584
18611
|
const rowNumber = strictToInteger(row, this.locale);
|
|
18585
18612
|
const colNumber = strictToInteger(column, this.locale);
|
|
@@ -18616,7 +18643,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18616
18643
|
args: [
|
|
18617
18644
|
arg("cell_reference (meta, default='this cell')", _t("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.")),
|
|
18618
18645
|
],
|
|
18619
|
-
returns: ["NUMBER"],
|
|
18620
18646
|
compute: function (cellReference) {
|
|
18621
18647
|
if (isEvaluationError(cellReference?.value)) {
|
|
18622
18648
|
throw cellReference;
|
|
@@ -18634,7 +18660,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18634
18660
|
const COLUMNS = {
|
|
18635
18661
|
description: _t("Number of columns in a specified array or range."),
|
|
18636
18662
|
args: [arg("range (meta)", _t("The range whose column count will be returned."))],
|
|
18637
|
-
returns: ["NUMBER"],
|
|
18638
18663
|
compute: function (range) {
|
|
18639
18664
|
if (isEvaluationError(range?.value)) {
|
|
18640
18665
|
throw range;
|
|
@@ -18655,7 +18680,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18655
18680
|
arg("index (number)", _t("The row index of the value to be returned, where the first row in range is numbered 1.")),
|
|
18656
18681
|
arg(`is_sorted (boolean, default=${DEFAULT_IS_SORTED})`, _t("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")),
|
|
18657
18682
|
],
|
|
18658
|
-
returns: ["ANY"],
|
|
18659
18683
|
compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18660
18684
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18661
18685
|
assert(() => 1 <= _index && _index <= range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
@@ -18685,7 +18709,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18685
18709
|
arg("row (number, default=0)", _t("The index of the row to be returned from within the reference range of cells.")),
|
|
18686
18710
|
arg("column (number, default=0)", _t("The index of the column to be returned from within the reference range of cells.")),
|
|
18687
18711
|
],
|
|
18688
|
-
returns: ["ANY"],
|
|
18689
18712
|
compute: function (reference, row = { value: 0 }, column = { value: 0 }) {
|
|
18690
18713
|
const _reference = toMatrix(reference);
|
|
18691
18714
|
const _row = toNumber(row.value, this.locale);
|
|
@@ -18716,7 +18739,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18716
18739
|
arg("reference (string)", _t("The range of cells from which the values are returned.")),
|
|
18717
18740
|
arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
|
|
18718
18741
|
],
|
|
18719
|
-
returns: ["ANY"],
|
|
18720
18742
|
compute: function (reference, useA1Notation = { value: true }) {
|
|
18721
18743
|
let _reference = reference?.value?.toString();
|
|
18722
18744
|
if (!_reference) {
|
|
@@ -18771,7 +18793,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18771
18793
|
arg("search_array (range)", _t("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),
|
|
18772
18794
|
arg("result_range (range, optional)", _t("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")),
|
|
18773
18795
|
],
|
|
18774
|
-
returns: ["ANY"],
|
|
18775
18796
|
compute: function (searchKey, searchArray, resultRange) {
|
|
18776
18797
|
let nbCol = searchArray.length;
|
|
18777
18798
|
let nbRow = searchArray[0].length;
|
|
@@ -18812,7 +18833,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18812
18833
|
arg("range (any, range)", _t("The one-dimensional array to be searched.")),
|
|
18813
18834
|
arg(`search_type (number, default=${DEFAULT_SEARCH_TYPE})`, _t("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")),
|
|
18814
18835
|
],
|
|
18815
|
-
returns: ["NUMBER"],
|
|
18816
18836
|
compute: function (searchKey, range, searchType = { value: DEFAULT_SEARCH_TYPE }) {
|
|
18817
18837
|
let _searchType = toNumber(searchType, this.locale);
|
|
18818
18838
|
const nbCol = range.length;
|
|
@@ -18851,7 +18871,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18851
18871
|
args: [
|
|
18852
18872
|
arg("cell_reference (meta, default='this cell')", _t("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.")),
|
|
18853
18873
|
],
|
|
18854
|
-
returns: ["NUMBER"],
|
|
18855
18874
|
compute: function (cellReference) {
|
|
18856
18875
|
if (isEvaluationError(cellReference?.value)) {
|
|
18857
18876
|
throw cellReference;
|
|
@@ -18869,7 +18888,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18869
18888
|
const ROWS = {
|
|
18870
18889
|
description: _t("Number of rows in a specified array or range."),
|
|
18871
18890
|
args: [arg("range (meta)", _t("The range whose row count will be returned."))],
|
|
18872
|
-
returns: ["NUMBER"],
|
|
18873
18891
|
compute: function (range) {
|
|
18874
18892
|
if (isEvaluationError(range?.value)) {
|
|
18875
18893
|
throw range;
|
|
@@ -18890,7 +18908,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18890
18908
|
arg("index (number)", _t("The column index of the value to be returned, where the first column in range is numbered 1.")),
|
|
18891
18909
|
arg(`is_sorted (boolean, default=${DEFAULT_IS_SORTED})`, _t("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")),
|
|
18892
18910
|
],
|
|
18893
|
-
returns: ["ANY"],
|
|
18894
18911
|
compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18895
18912
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18896
18913
|
assert(() => 1 <= _index && _index <= range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
@@ -18936,7 +18953,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18936
18953
|
(-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned.\
|
|
18937
18954
|
")),
|
|
18938
18955
|
],
|
|
18939
|
-
returns: ["ANY"],
|
|
18940
18956
|
compute: function (searchKey, lookupRange, returnRange, defaultValue, matchMode = { value: DEFAULT_MATCH_MODE }, searchMode = { value: DEFAULT_SEARCH_MODE }) {
|
|
18941
18957
|
const _matchMode = Math.trunc(toNumber(matchMode.value, this.locale));
|
|
18942
18958
|
const _searchMode = Math.trunc(toNumber(searchMode.value, this.locale));
|
|
@@ -18992,12 +19008,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18992
19008
|
assertDomainLength(_domainArgs);
|
|
18993
19009
|
const pivot = this.getters.getPivot(pivotId);
|
|
18994
19010
|
const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
|
|
18995
|
-
if (!supportedPivotExplodedFormulaRegistry.get(coreDefinition.type)) {
|
|
18996
|
-
return {
|
|
18997
|
-
value: CellErrorType.GenericError,
|
|
18998
|
-
message: _t("This pivot does not support PIVOT.VALUE formula"),
|
|
18999
|
-
};
|
|
19000
|
-
}
|
|
19001
19011
|
addPivotDependencies(this, coreDefinition);
|
|
19002
19012
|
const error = pivot.assertIsValid({ throwOnError: false });
|
|
19003
19013
|
if (error) {
|
|
@@ -19013,7 +19023,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19013
19023
|
}
|
|
19014
19024
|
return { value, format };
|
|
19015
19025
|
},
|
|
19016
|
-
returns: ["NUMBER", "STRING"],
|
|
19017
19026
|
};
|
|
19018
19027
|
const PIVOT_HEADER = {
|
|
19019
19028
|
description: _t("Get the header of a pivot."),
|
|
@@ -19029,12 +19038,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19029
19038
|
assertDomainLength(_domainArgs);
|
|
19030
19039
|
const pivot = this.getters.getPivot(_pivotId);
|
|
19031
19040
|
const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
|
|
19032
|
-
if (!supportedPivotExplodedFormulaRegistry.get(coreDefinition.type)) {
|
|
19033
|
-
return {
|
|
19034
|
-
value: CellErrorType.GenericError,
|
|
19035
|
-
message: _t("This pivot does not support PIVOT.VALUE formula"),
|
|
19036
|
-
};
|
|
19037
|
-
}
|
|
19038
19041
|
addPivotDependencies(this, coreDefinition);
|
|
19039
19042
|
const error = pivot.assertIsValid({ throwOnError: false });
|
|
19040
19043
|
if (error) {
|
|
@@ -19059,7 +19062,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19059
19062
|
: format,
|
|
19060
19063
|
};
|
|
19061
19064
|
},
|
|
19062
|
-
returns: ["NUMBER", "STRING"],
|
|
19063
19065
|
};
|
|
19064
19066
|
const PIVOT = {
|
|
19065
19067
|
description: _t("Get a pivot table."),
|
|
@@ -19126,7 +19128,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19126
19128
|
}
|
|
19127
19129
|
return result;
|
|
19128
19130
|
},
|
|
19129
|
-
returns: ["RANGE<ANY>"],
|
|
19130
19131
|
};
|
|
19131
19132
|
|
|
19132
19133
|
var lookup = /*#__PURE__*/Object.freeze({
|
|
@@ -19157,7 +19158,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19157
19158
|
arg("value1 (number)", _t("The first addend.")),
|
|
19158
19159
|
arg("value2 (number)", _t("The second addend.")),
|
|
19159
19160
|
],
|
|
19160
|
-
returns: ["NUMBER"],
|
|
19161
19161
|
compute: function (value1, value2) {
|
|
19162
19162
|
return {
|
|
19163
19163
|
value: toNumber(value1, this.locale) + toNumber(value2, this.locale),
|
|
@@ -19174,7 +19174,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19174
19174
|
arg("value1 (string)", _t("The value to which value2 will be appended.")),
|
|
19175
19175
|
arg("value2 (string)", _t("The value to append to value1.")),
|
|
19176
19176
|
],
|
|
19177
|
-
returns: ["STRING"],
|
|
19178
19177
|
compute: function (value1, value2) {
|
|
19179
19178
|
return toString(value1) + toString(value2);
|
|
19180
19179
|
},
|
|
@@ -19189,7 +19188,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19189
19188
|
arg("dividend (number)", _t("The number to be divided.")),
|
|
19190
19189
|
arg("divisor (number)", _t("The number to divide by.")),
|
|
19191
19190
|
],
|
|
19192
|
-
returns: ["NUMBER"],
|
|
19193
19191
|
compute: function (dividend, divisor) {
|
|
19194
19192
|
const _divisor = toNumber(divisor, this.locale);
|
|
19195
19193
|
assert(() => _divisor !== 0, _t("The divisor must be different from zero."), CellErrorType.DivisionByZero);
|
|
@@ -19212,7 +19210,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19212
19210
|
arg("value1 (any)", _t("The first value.")),
|
|
19213
19211
|
arg("value2 (any)", _t("The value to test against value1 for equality.")),
|
|
19214
19212
|
],
|
|
19215
|
-
returns: ["BOOLEAN"],
|
|
19216
19213
|
compute: function (value1, value2) {
|
|
19217
19214
|
let _value1 = isEmpty(value1) ? getNeutral[typeof value2?.value] : value1?.value;
|
|
19218
19215
|
let _value2 = isEmpty(value2) ? getNeutral[typeof value1?.value] : value2?.value;
|
|
@@ -19265,7 +19262,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19265
19262
|
arg("value1 (any)", _t("The value to test as being greater than value2.")),
|
|
19266
19263
|
arg("value2 (any)", _t("The second value.")),
|
|
19267
19264
|
],
|
|
19268
|
-
returns: ["BOOLEAN"],
|
|
19269
19265
|
compute: function (value1, value2) {
|
|
19270
19266
|
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
19271
19267
|
return v1 > v2;
|
|
@@ -19281,7 +19277,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19281
19277
|
arg("value1 (any)", _t("The value to test as being greater than or equal to value2.")),
|
|
19282
19278
|
arg("value2 (any)", _t("The second value.")),
|
|
19283
19279
|
],
|
|
19284
|
-
returns: ["BOOLEAN"],
|
|
19285
19280
|
compute: function (value1, value2) {
|
|
19286
19281
|
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
19287
19282
|
return v1 >= v2;
|
|
@@ -19297,7 +19292,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19297
19292
|
arg("value1 (any)", _t("The value to test as being less than value2.")),
|
|
19298
19293
|
arg("value2 (any)", _t("The second value.")),
|
|
19299
19294
|
],
|
|
19300
|
-
returns: ["BOOLEAN"],
|
|
19301
19295
|
compute: function (value1, value2) {
|
|
19302
19296
|
return !GTE.compute.bind(this)(value1, value2);
|
|
19303
19297
|
},
|
|
@@ -19311,7 +19305,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19311
19305
|
arg("value1 (any)", _t("The value to test as being less than or equal to value2.")),
|
|
19312
19306
|
arg("value2 (any)", _t("The second value.")),
|
|
19313
19307
|
],
|
|
19314
|
-
returns: ["BOOLEAN"],
|
|
19315
19308
|
compute: function (value1, value2) {
|
|
19316
19309
|
return !GT.compute.bind(this)(value1, value2);
|
|
19317
19310
|
},
|
|
@@ -19325,7 +19318,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19325
19318
|
arg("value1 (number)", _t("The minuend, or number to be subtracted from.")),
|
|
19326
19319
|
arg("value2 (number)", _t("The subtrahend, or number to subtract from value1.")),
|
|
19327
19320
|
],
|
|
19328
|
-
returns: ["NUMBER"],
|
|
19329
19321
|
compute: function (value1, value2) {
|
|
19330
19322
|
return {
|
|
19331
19323
|
value: toNumber(value1, this.locale) - toNumber(value2, this.locale),
|
|
@@ -19342,7 +19334,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19342
19334
|
arg("factor1 (number)", _t("The first multiplicand.")),
|
|
19343
19335
|
arg("factor2 (number)", _t("The second multiplicand.")),
|
|
19344
19336
|
],
|
|
19345
|
-
returns: ["NUMBER"],
|
|
19346
19337
|
compute: function (factor1, factor2) {
|
|
19347
19338
|
return {
|
|
19348
19339
|
value: toNumber(factor1, this.locale) * toNumber(factor2, this.locale),
|
|
@@ -19359,7 +19350,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19359
19350
|
arg("value1 (any)", _t("The first value.")),
|
|
19360
19351
|
arg("value2 (any)", _t("The value to test against value1 for inequality.")),
|
|
19361
19352
|
],
|
|
19362
|
-
returns: ["BOOLEAN"],
|
|
19363
19353
|
compute: function (value1, value2) {
|
|
19364
19354
|
return !EQ.compute.bind(this)(value1, value2);
|
|
19365
19355
|
},
|
|
@@ -19373,7 +19363,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19373
19363
|
arg("base (number)", _t("The number to raise to the exponent power.")),
|
|
19374
19364
|
arg("exponent (number)", _t("The exponent to raise base to.")),
|
|
19375
19365
|
],
|
|
19376
|
-
returns: ["NUMBER"],
|
|
19377
19366
|
compute: function (base, exponent) {
|
|
19378
19367
|
return POWER.compute.bind(this)(base, exponent);
|
|
19379
19368
|
},
|
|
@@ -19386,7 +19375,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19386
19375
|
args: [
|
|
19387
19376
|
arg("value (number)", _t("The number to have its sign reversed. Equivalently, the number to multiply by -1.")),
|
|
19388
19377
|
],
|
|
19389
|
-
returns: ["NUMBER"],
|
|
19390
19378
|
compute: function (value) {
|
|
19391
19379
|
return {
|
|
19392
19380
|
value: -toNumber(value, this.locale),
|
|
@@ -19400,7 +19388,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19400
19388
|
const UNARY_PERCENT = {
|
|
19401
19389
|
description: _t("Value interpreted as a percentage."),
|
|
19402
19390
|
args: [arg("percentage (number)", _t("The value to interpret as a percentage."))],
|
|
19403
|
-
returns: ["NUMBER"],
|
|
19404
19391
|
compute: function (percentage) {
|
|
19405
19392
|
return toNumber(percentage, this.locale) / 100;
|
|
19406
19393
|
},
|
|
@@ -19411,7 +19398,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19411
19398
|
const UPLUS = {
|
|
19412
19399
|
description: _t("A specified number, unchanged."),
|
|
19413
19400
|
args: [arg("value (any)", _t("The number to return."))],
|
|
19414
|
-
returns: ["ANY"],
|
|
19415
19401
|
compute: function (value = { value: null }) {
|
|
19416
19402
|
return value;
|
|
19417
19403
|
},
|
|
@@ -19447,7 +19433,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19447
19433
|
args: [
|
|
19448
19434
|
arg("table_number (number)", _t("The number of the character to look up from the current Unicode table in decimal format.")),
|
|
19449
19435
|
],
|
|
19450
|
-
returns: ["STRING"],
|
|
19451
19436
|
compute: function (tableNumber) {
|
|
19452
19437
|
const _tableNumber = Math.trunc(toNumber(tableNumber, this.locale));
|
|
19453
19438
|
assert(() => _tableNumber >= 1, _t("The table_number (%s) is out of range.", _tableNumber.toString()));
|
|
@@ -19461,7 +19446,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19461
19446
|
const CLEAN = {
|
|
19462
19447
|
description: _t("Remove non-printable characters from a piece of text."),
|
|
19463
19448
|
args: [arg("text (string)", _t("The text whose non-printable characters are to be removed."))],
|
|
19464
|
-
returns: ["STRING"],
|
|
19465
19449
|
compute: function (text) {
|
|
19466
19450
|
const _text = toString(text);
|
|
19467
19451
|
let cleanedStr = "";
|
|
@@ -19483,7 +19467,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19483
19467
|
arg("string1 (string, range<string>)", _t("The initial string.")),
|
|
19484
19468
|
arg("string2 (string, range<string>, repeating)", _t("More strings to append in sequence.")),
|
|
19485
19469
|
],
|
|
19486
|
-
returns: ["STRING"],
|
|
19487
19470
|
compute: function (...datas) {
|
|
19488
19471
|
return reduceAny(datas, (acc, a) => acc + toString(a), "");
|
|
19489
19472
|
},
|
|
@@ -19498,7 +19481,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19498
19481
|
arg("string1 (string)", _t("The first string to compare.")),
|
|
19499
19482
|
arg("string2 (string)", _t("The second string to compare.")),
|
|
19500
19483
|
],
|
|
19501
|
-
returns: ["BOOLEAN"],
|
|
19502
19484
|
compute: function (string1, string2) {
|
|
19503
19485
|
return toString(string1) === toString(string2);
|
|
19504
19486
|
},
|
|
@@ -19514,7 +19496,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19514
19496
|
arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
|
|
19515
19497
|
arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
|
|
19516
19498
|
],
|
|
19517
|
-
returns: ["NUMBER"],
|
|
19518
19499
|
compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
|
|
19519
19500
|
const _searchFor = toString(searchFor);
|
|
19520
19501
|
const _textToSearch = toString(textToSearch);
|
|
@@ -19537,7 +19518,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19537
19518
|
arg("value_or_array1 (string, range<string>)", _t("The value or values to be appended using delimiter.")),
|
|
19538
19519
|
arg("value_or_array2 (string, range<string>, repeating)", _t("More values to be appended using delimiter.")),
|
|
19539
19520
|
],
|
|
19540
|
-
returns: ["STRING"],
|
|
19541
19521
|
compute: function (delimiter, ...valuesOrArrays) {
|
|
19542
19522
|
const _delimiter = toString(delimiter);
|
|
19543
19523
|
return reduceAny(valuesOrArrays, (acc, a) => (acc ? acc + _delimiter : "") + toString(a), "");
|
|
@@ -19552,7 +19532,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19552
19532
|
arg("text (string)", _t("The string from which the left portion will be returned.")),
|
|
19553
19533
|
arg("number_of_characters (number, optional)", _t("The number of characters to return from the left side of string.")),
|
|
19554
19534
|
],
|
|
19555
|
-
returns: ["STRING"],
|
|
19556
19535
|
compute: function (text, ...args) {
|
|
19557
19536
|
const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
|
|
19558
19537
|
assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
|
|
@@ -19566,7 +19545,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19566
19545
|
const LEN = {
|
|
19567
19546
|
description: _t("Length of a string."),
|
|
19568
19547
|
args: [arg("text (string)", _t("The string whose length will be returned."))],
|
|
19569
|
-
returns: ["NUMBER"],
|
|
19570
19548
|
compute: function (text) {
|
|
19571
19549
|
return toString(text).length;
|
|
19572
19550
|
},
|
|
@@ -19578,7 +19556,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19578
19556
|
const LOWER = {
|
|
19579
19557
|
description: _t("Converts a specified string to lowercase."),
|
|
19580
19558
|
args: [arg("text (string)", _t("The string to convert to lowercase."))],
|
|
19581
|
-
returns: ["STRING"],
|
|
19582
19559
|
compute: function (text) {
|
|
19583
19560
|
return toString(text).toLowerCase();
|
|
19584
19561
|
},
|
|
@@ -19594,7 +19571,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19594
19571
|
arg("starting_at (number)", _t("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),
|
|
19595
19572
|
arg("extract_length (number)", _t("The length of the segment to extract.")),
|
|
19596
19573
|
],
|
|
19597
|
-
returns: ["STRING"],
|
|
19598
19574
|
compute: function (text, starting_at, extract_length) {
|
|
19599
19575
|
const _text = toString(text);
|
|
19600
19576
|
const _starting_at = toNumber(starting_at, this.locale);
|
|
@@ -19613,7 +19589,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19613
19589
|
args: [
|
|
19614
19590
|
arg("text_to_capitalize (string)", _t("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")),
|
|
19615
19591
|
],
|
|
19616
|
-
returns: ["STRING"],
|
|
19617
19592
|
compute: function (text) {
|
|
19618
19593
|
const _text = toString(text);
|
|
19619
19594
|
return _text.replace(wordRegex, (word) => {
|
|
@@ -19633,7 +19608,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19633
19608
|
arg("length (number)", _t("The number of characters in the text to be replaced.")),
|
|
19634
19609
|
arg("new_text (string)", _t("The text which will be inserted into the original text.")),
|
|
19635
19610
|
],
|
|
19636
|
-
returns: ["STRING"],
|
|
19637
19611
|
compute: function (text, position, length, newText) {
|
|
19638
19612
|
const _position = toNumber(position, this.locale);
|
|
19639
19613
|
assert(() => _position >= 1, _t("The position (%s) must be greater than or equal to 1.", _position.toString()));
|
|
@@ -19653,7 +19627,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19653
19627
|
arg("text (string)", _t("The string from which the right portion will be returned.")),
|
|
19654
19628
|
arg("number_of_characters (number, optional)", _t("The number of characters to return from the right side of string.")),
|
|
19655
19629
|
],
|
|
19656
|
-
returns: ["STRING"],
|
|
19657
19630
|
compute: function (text, ...args) {
|
|
19658
19631
|
const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
|
|
19659
19632
|
assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
|
|
@@ -19673,7 +19646,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19673
19646
|
arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
|
|
19674
19647
|
arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
|
|
19675
19648
|
],
|
|
19676
|
-
returns: ["NUMBER"],
|
|
19677
19649
|
compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
|
|
19678
19650
|
const _searchFor = toString(searchFor).toLowerCase();
|
|
19679
19651
|
const _textToSearch = toString(textToSearch).toLowerCase();
|
|
@@ -19700,7 +19672,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19700
19672
|
arg(`remove_empty_text (boolean, default=${SPLIT_DEFAULT_REMOVE_EMPTY_TEXT})`, _t("Whether or not to remove empty text messages from the split results. The default behavior is to treat \
|
|
19701
19673
|
consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.")),
|
|
19702
19674
|
],
|
|
19703
|
-
returns: ["RANGE<STRING>"],
|
|
19704
19675
|
compute: function (text, delimiter, splitByEach = { value: SPLIT_DEFAULT_SPLIT_BY_EACH }, removeEmptyText = { value: SPLIT_DEFAULT_REMOVE_EMPTY_TEXT }) {
|
|
19705
19676
|
const _text = toString(text);
|
|
19706
19677
|
const _delimiter = escapeRegExp(toString(delimiter));
|
|
@@ -19727,7 +19698,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19727
19698
|
arg("replace_with (string)", _t("The string that will replace search_for.")),
|
|
19728
19699
|
arg("occurrence_number (number, optional)", _t("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")),
|
|
19729
19700
|
],
|
|
19730
|
-
returns: ["NUMBER"],
|
|
19731
19701
|
compute: function (textToSearch, searchFor, replaceWith, occurrenceNumber) {
|
|
19732
19702
|
const _occurrenceNumber = toNumber(occurrenceNumber, this.locale);
|
|
19733
19703
|
assert(() => _occurrenceNumber >= 0, _t("The occurrenceNumber (%s) must be positive or null.", _occurrenceNumber.toString()));
|
|
@@ -19757,7 +19727,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19757
19727
|
arg("text1 (string, range<string>)", _t("Any text item. This could be a string, or an array of strings in a range.")),
|
|
19758
19728
|
arg("text2 (string, range<string>, repeating)", _t("Additional text item(s).")),
|
|
19759
19729
|
],
|
|
19760
|
-
returns: ["STRING"],
|
|
19761
19730
|
compute: function (delimiter, ignoreEmpty, ...textsOrArrays) {
|
|
19762
19731
|
const _delimiter = toString(delimiter);
|
|
19763
19732
|
const _ignoreEmpty = toBoolean(ignoreEmpty);
|
|
@@ -19774,7 +19743,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19774
19743
|
args: [
|
|
19775
19744
|
arg("text (string)", _t("The text or reference to a cell containing text to be trimmed.")),
|
|
19776
19745
|
],
|
|
19777
|
-
returns: ["STRING"],
|
|
19778
19746
|
compute: function (text) {
|
|
19779
19747
|
return trimContent(toString(text));
|
|
19780
19748
|
},
|
|
@@ -19786,7 +19754,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19786
19754
|
const UPPER = {
|
|
19787
19755
|
description: _t("Converts a specified string to uppercase."),
|
|
19788
19756
|
args: [arg("text (string)", _t("The string to convert to uppercase."))],
|
|
19789
|
-
returns: ["STRING"],
|
|
19790
19757
|
compute: function (text) {
|
|
19791
19758
|
return toString(text).toUpperCase();
|
|
19792
19759
|
},
|
|
@@ -19801,7 +19768,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19801
19768
|
arg("number (number)", _t("The number, date or time to format.")),
|
|
19802
19769
|
arg("format (string)", _t("The pattern by which to format the number, enclosed in quotation marks.")),
|
|
19803
19770
|
],
|
|
19804
|
-
returns: ["STRING"],
|
|
19805
19771
|
compute: function (number, format) {
|
|
19806
19772
|
const _number = toNumber(number, this.locale);
|
|
19807
19773
|
return formatValue(_number, { format: toString(format), locale: this.locale });
|
|
@@ -19842,7 +19808,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19842
19808
|
arg("url (string)", _t("The full URL of the link enclosed in quotation marks.")),
|
|
19843
19809
|
arg("link_label (string, optional)", _t("The text to display in the cell, enclosed in quotation marks.")),
|
|
19844
19810
|
],
|
|
19845
|
-
returns: ["STRING"],
|
|
19846
19811
|
compute: function (url, linkLabel) {
|
|
19847
19812
|
const processedUrl = toString(url).trim();
|
|
19848
19813
|
const processedLabel = toString(linkLabel) || processedUrl;
|
|
@@ -19901,6 +19866,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19901
19866
|
}
|
|
19902
19867
|
args[i] = arg[0][0];
|
|
19903
19868
|
}
|
|
19869
|
+
if (!isMatrix(arg) && argDefinition.acceptMatrixOnly) {
|
|
19870
|
+
throw new BadExpressionError(_t("Function [[FUNCTION_NAME]] expects the parameter '%s' to be reference to a cell or range.", (i + 1).toString()));
|
|
19871
|
+
}
|
|
19904
19872
|
}
|
|
19905
19873
|
return descr.compute.apply(this, args);
|
|
19906
19874
|
}
|
|
@@ -21495,12 +21463,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21495
21463
|
// detect when an argument need to be evaluated as a meta argument
|
|
21496
21464
|
const isMeta = argTypes.includes("META");
|
|
21497
21465
|
const hasRange = argTypes.some((t) => isRangeType(t));
|
|
21498
|
-
const isRangeOnly = argTypes.every((t) => isRangeType(t));
|
|
21499
|
-
if (isRangeOnly) {
|
|
21500
|
-
if (!isRangeInput(currentArg)) {
|
|
21501
|
-
throw new BadExpressionError(_t("Function %(function_name)s expects the parameter %(arg_index)s to be a reference to a cell or a range.", { function_name: functionName, arg_index: i + 1 }));
|
|
21502
|
-
}
|
|
21503
|
-
}
|
|
21504
21466
|
compiledArgs.push(compileAST(currentArg, isMeta, hasRange));
|
|
21505
21467
|
}
|
|
21506
21468
|
return compiledArgs;
|
|
@@ -21665,16 +21627,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21665
21627
|
function isRangeType(type) {
|
|
21666
21628
|
return type.startsWith("RANGE");
|
|
21667
21629
|
}
|
|
21668
|
-
function isRangeInput(arg) {
|
|
21669
|
-
if (arg.type === "REFERENCE") {
|
|
21670
|
-
return true;
|
|
21671
|
-
}
|
|
21672
|
-
if (arg.type === "FUNCALL") {
|
|
21673
|
-
const fnDef = functions$1[arg.value.toUpperCase()];
|
|
21674
|
-
return fnDef && isRangeType(fnDef.returns[0]);
|
|
21675
|
-
}
|
|
21676
|
-
return false;
|
|
21677
|
-
}
|
|
21678
21630
|
|
|
21679
21631
|
const functions = functionRegistry.content;
|
|
21680
21632
|
function isExportableToExcel(tokens) {
|
|
@@ -21718,11 +21670,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21718
21670
|
function makeFieldProposal(field, granularity) {
|
|
21719
21671
|
const groupBy = granularity ? `${field.name}:${granularity}` : field.name;
|
|
21720
21672
|
const quotedGroupBy = `"${groupBy}"`;
|
|
21673
|
+
const fuzzySearchKey = field.string !== field.name
|
|
21674
|
+
? field.string + quotedGroupBy // search on translated name and on technical name
|
|
21675
|
+
: quotedGroupBy;
|
|
21721
21676
|
return {
|
|
21722
21677
|
text: quotedGroupBy,
|
|
21723
21678
|
description: field.string + (field.help ? ` (${field.help})` : ""),
|
|
21724
21679
|
htmlContent: [{ value: quotedGroupBy, color: tokenColors.STRING }],
|
|
21725
|
-
fuzzySearchKey
|
|
21680
|
+
fuzzySearchKey,
|
|
21726
21681
|
};
|
|
21727
21682
|
}
|
|
21728
21683
|
/**
|
|
@@ -21782,6 +21737,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21782
21737
|
return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS).length;
|
|
21783
21738
|
}
|
|
21784
21739
|
|
|
21740
|
+
/**
|
|
21741
|
+
* Registry to enable or disable the support of positional arguments
|
|
21742
|
+
* (with a leading #) in pivot functions
|
|
21743
|
+
* e.g. =PIVOT.VALUE(1,"probability","#stage",1)
|
|
21744
|
+
*/
|
|
21745
|
+
const supportedPivotPositionalFormulaRegistry = new Registry();
|
|
21746
|
+
supportedPivotPositionalFormulaRegistry.add("SPREADSHEET", false);
|
|
21747
|
+
|
|
21785
21748
|
autoCompleteProviders.add("pivot_ids", {
|
|
21786
21749
|
sequence: 50,
|
|
21787
21750
|
autoSelectFirstProposal: true,
|
|
@@ -21800,10 +21763,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21800
21763
|
return pivotIds
|
|
21801
21764
|
.map((pivotId) => {
|
|
21802
21765
|
const definition = this.getters.getPivotCoreDefinition(pivotId);
|
|
21803
|
-
if (functionContext.parent.toUpperCase() !== "PIVOT" &&
|
|
21804
|
-
!supportedPivotExplodedFormulaRegistry.get(definition.type)) {
|
|
21805
|
-
return undefined;
|
|
21806
|
-
}
|
|
21807
21766
|
const formulaId = this.getters.getPivotFormulaId(pivotId);
|
|
21808
21767
|
const str = `${formulaId}`;
|
|
21809
21768
|
return {
|
|
@@ -21831,15 +21790,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21831
21790
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21832
21791
|
return [];
|
|
21833
21792
|
}
|
|
21834
|
-
const
|
|
21835
|
-
|
|
21793
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21794
|
+
pivot.init();
|
|
21795
|
+
const fields = pivot.getFields();
|
|
21836
21796
|
if (!fields) {
|
|
21837
21797
|
return [];
|
|
21838
21798
|
}
|
|
21839
21799
|
const definition = this.getters.getPivotCoreDefinition(pivotId);
|
|
21840
|
-
if (!supportedPivotExplodedFormulaRegistry.get(definition.type)) {
|
|
21841
|
-
return [];
|
|
21842
|
-
}
|
|
21843
21800
|
return definition.measures
|
|
21844
21801
|
.map((measure) => {
|
|
21845
21802
|
if (measure.name === "__count") {
|
|
@@ -21875,16 +21832,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21875
21832
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21876
21833
|
return;
|
|
21877
21834
|
}
|
|
21878
|
-
const
|
|
21879
|
-
|
|
21835
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21836
|
+
pivot.init();
|
|
21837
|
+
const fields = pivot.getFields();
|
|
21880
21838
|
if (!fields) {
|
|
21881
21839
|
return;
|
|
21882
21840
|
}
|
|
21883
|
-
const {
|
|
21884
|
-
const { columns, rows } = dataSource.definition;
|
|
21885
|
-
if (!supportedPivotExplodedFormulaRegistry.get(type)) {
|
|
21886
|
-
return [];
|
|
21887
|
-
}
|
|
21841
|
+
const { columns, rows } = pivot.definition;
|
|
21888
21842
|
let args = functionContext.args;
|
|
21889
21843
|
if (functionContext?.parent.toUpperCase() === "PIVOT.VALUE") {
|
|
21890
21844
|
args = args.filter((ast, index) => index % 2 === 0); // keep only the field names
|
|
@@ -21921,6 +21875,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21921
21875
|
return field ? makeFieldProposal(field, granularity) : undefined;
|
|
21922
21876
|
})
|
|
21923
21877
|
.concat(groupBys.map((groupBy) => {
|
|
21878
|
+
if (!supportedPivotPositionalFormulaRegistry.get(pivot.type)) {
|
|
21879
|
+
return undefined;
|
|
21880
|
+
}
|
|
21924
21881
|
const fieldName = groupBy.split(":")[0];
|
|
21925
21882
|
const field = fields[fieldName];
|
|
21926
21883
|
if (!field) {
|
|
@@ -21969,12 +21926,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21969
21926
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21970
21927
|
return;
|
|
21971
21928
|
}
|
|
21972
|
-
const
|
|
21973
|
-
if (!
|
|
21974
|
-
return [];
|
|
21975
|
-
}
|
|
21976
|
-
const dataSource = this.getters.getPivot(pivotId);
|
|
21977
|
-
if (!dataSource.isValid()) {
|
|
21929
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21930
|
+
if (!pivot.isValid()) {
|
|
21978
21931
|
return;
|
|
21979
21932
|
}
|
|
21980
21933
|
const argPosition = functionContext.argPosition;
|
|
@@ -21982,7 +21935,46 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21982
21935
|
if (!groupByField) {
|
|
21983
21936
|
return;
|
|
21984
21937
|
}
|
|
21985
|
-
|
|
21938
|
+
let dimension;
|
|
21939
|
+
try {
|
|
21940
|
+
dimension = pivot.definition.getDimension(groupByField);
|
|
21941
|
+
}
|
|
21942
|
+
catch (error) {
|
|
21943
|
+
return undefined;
|
|
21944
|
+
}
|
|
21945
|
+
if (dimension.granularity === "month_number") {
|
|
21946
|
+
return Object.values(MONTHS).map((monthDisplayName, index) => ({
|
|
21947
|
+
text: `${index + 1}`,
|
|
21948
|
+
fuzzySearchKey: monthDisplayName.toString(),
|
|
21949
|
+
description: monthDisplayName.toString(),
|
|
21950
|
+
htmlContent: [{ value: `${index + 1}`, color: tokenColors.NUMBER }],
|
|
21951
|
+
}));
|
|
21952
|
+
}
|
|
21953
|
+
else if (dimension.granularity === "quarter_number") {
|
|
21954
|
+
return [1, 2, 3, 4].map((quarter) => ({
|
|
21955
|
+
text: `${quarter}`,
|
|
21956
|
+
fuzzySearchKey: `${quarter}`,
|
|
21957
|
+
description: _t("Quarter %s", quarter),
|
|
21958
|
+
htmlContent: [{ value: `${quarter}`, color: tokenColors.NUMBER }],
|
|
21959
|
+
}));
|
|
21960
|
+
}
|
|
21961
|
+
else if (dimension.granularity === "day_of_month") {
|
|
21962
|
+
return range(1, 32).map((dayOfMonth) => ({
|
|
21963
|
+
text: `${dayOfMonth}`,
|
|
21964
|
+
fuzzySearchKey: `${dayOfMonth}`,
|
|
21965
|
+
description: "",
|
|
21966
|
+
htmlContent: [{ value: `${dayOfMonth}`, color: tokenColors.NUMBER }],
|
|
21967
|
+
}));
|
|
21968
|
+
}
|
|
21969
|
+
else if (dimension.granularity === "iso_week_number") {
|
|
21970
|
+
return range(0, 54).map((isoWeekNumber) => ({
|
|
21971
|
+
text: `${isoWeekNumber}`,
|
|
21972
|
+
fuzzySearchKey: `${isoWeekNumber}`,
|
|
21973
|
+
description: "",
|
|
21974
|
+
htmlContent: [{ value: `${isoWeekNumber}`, color: tokenColors.NUMBER }],
|
|
21975
|
+
}));
|
|
21976
|
+
}
|
|
21977
|
+
return pivot.getPossibleFieldValues(dimension).map(({ value, label }) => {
|
|
21986
21978
|
const isString = typeof value === "string";
|
|
21987
21979
|
const text = isString ? `"${value}"` : value.toString();
|
|
21988
21980
|
const color = isString ? tokenColors.STRING : tokenColors.NUMBER;
|
|
@@ -22089,7 +22081,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22089
22081
|
tooltip: content
|
|
22090
22082
|
? {
|
|
22091
22083
|
props: {
|
|
22092
|
-
content:
|
|
22084
|
+
content: data.cell
|
|
22085
|
+
? evaluateLiteral(data.cell, localeFormat).formattedValue
|
|
22086
|
+
: "",
|
|
22093
22087
|
},
|
|
22094
22088
|
}
|
|
22095
22089
|
: undefined,
|
|
@@ -22152,9 +22146,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22152
22146
|
if (x === cell) {
|
|
22153
22147
|
found = true;
|
|
22154
22148
|
}
|
|
22155
|
-
const cellValue = x
|
|
22156
|
-
? undefined
|
|
22157
|
-
: evaluateLiteral(x?.content, { locale: DEFAULT_LOCALE });
|
|
22149
|
+
const cellValue = x === undefined || x.isFormula ? undefined : evaluateLiteral(x, { locale: DEFAULT_LOCALE });
|
|
22158
22150
|
if (cellValue && filter(cellValue)) {
|
|
22159
22151
|
group.push(cellValue);
|
|
22160
22152
|
}
|
|
@@ -22202,7 +22194,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22202
22194
|
})
|
|
22203
22195
|
.add("increment_alphanumeric_value", {
|
|
22204
22196
|
condition: (cell) => !cell.isFormula &&
|
|
22205
|
-
evaluateLiteral(cell
|
|
22197
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text &&
|
|
22206
22198
|
alphaNumericValueRegExp.test(cell.content),
|
|
22207
22199
|
generateRule: (cell, cells) => {
|
|
22208
22200
|
const numberPostfix = parseInt(cell.content.match(numberPostfixRegExp)[0]);
|
|
@@ -22225,7 +22217,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22225
22217
|
})
|
|
22226
22218
|
.add("copy_text", {
|
|
22227
22219
|
condition: (cell) => !cell.isFormula &&
|
|
22228
|
-
evaluateLiteral(cell
|
|
22220
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text,
|
|
22229
22221
|
generateRule: () => {
|
|
22230
22222
|
return { type: "COPY_MODIFIER" };
|
|
22231
22223
|
},
|
|
@@ -22240,11 +22232,11 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22240
22232
|
})
|
|
22241
22233
|
.add("increment_number", {
|
|
22242
22234
|
condition: (cell) => !cell.isFormula &&
|
|
22243
|
-
evaluateLiteral(cell
|
|
22235
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.number,
|
|
22244
22236
|
generateRule: (cell, cells) => {
|
|
22245
22237
|
const group = getGroup(cell, cells, (evaluatedCell) => evaluatedCell.type === CellValueType.number).map((cell) => Number(cell.value));
|
|
22246
22238
|
const increment = calculateIncrementBasedOnGroup(group);
|
|
22247
|
-
const evaluation = evaluateLiteral(cell
|
|
22239
|
+
const evaluation = evaluateLiteral(cell, { locale: DEFAULT_LOCALE });
|
|
22248
22240
|
return {
|
|
22249
22241
|
type: "INCREMENT_MODIFIER",
|
|
22250
22242
|
increment,
|
|
@@ -25468,7 +25460,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25468
25460
|
if (!anchor)
|
|
25469
25461
|
return;
|
|
25470
25462
|
const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
|
|
25471
|
-
|
|
25463
|
+
let elDims = {
|
|
25472
25464
|
width: el.getBoundingClientRect().width,
|
|
25473
25465
|
height: el.getBoundingClientRect().height,
|
|
25474
25466
|
};
|
|
@@ -25476,7 +25468,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25476
25468
|
const popoverPositionHelper = this.props.positioning === "BottomLeft"
|
|
25477
25469
|
? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
|
|
25478
25470
|
: new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
|
|
25479
|
-
|
|
25471
|
+
el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
|
|
25472
|
+
el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
|
|
25473
|
+
// Re-compute the dimensions after setting the max-width and max-height
|
|
25474
|
+
elDims = {
|
|
25475
|
+
width: el.getBoundingClientRect().width,
|
|
25476
|
+
height: el.getBoundingClientRect().height,
|
|
25477
|
+
};
|
|
25478
|
+
let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
|
|
25480
25479
|
for (const property of Object.keys(style)) {
|
|
25481
25480
|
el.style[property] = style[property];
|
|
25482
25481
|
}
|
|
@@ -25539,8 +25538,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25539
25538
|
const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
|
|
25540
25539
|
verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
|
|
25541
25540
|
const cssProperties = {
|
|
25542
|
-
"max-height": maxHeight + "px",
|
|
25543
|
-
"max-width": maxWidth + "px",
|
|
25544
25541
|
top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
|
|
25545
25542
|
this.spreadsheetOffset.y -
|
|
25546
25543
|
verticalOffset +
|
|
@@ -31354,10 +31351,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31354
31351
|
|
|
31355
31352
|
class AxisDesignEditor extends owl.Component {
|
|
31356
31353
|
static template = "o-spreadsheet-AxisDesignEditor";
|
|
31357
|
-
static components = {
|
|
31358
|
-
|
|
31359
|
-
ChartTitle,
|
|
31360
|
-
};
|
|
31354
|
+
static components = { Section, ChartTitle };
|
|
31355
|
+
static props = { figureId: String, definition: Object, updateChart: Function, axesList: Array };
|
|
31361
31356
|
state = owl.useState({ currentAxis: "x" });
|
|
31362
31357
|
get axisTitleStyle() {
|
|
31363
31358
|
const axisDesign = this.props.definition.axesDesign?.[this.state.currentAxis] ?? {};
|
|
@@ -31508,6 +31503,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31508
31503
|
AxisDesignEditor,
|
|
31509
31504
|
RoundColorPicker,
|
|
31510
31505
|
};
|
|
31506
|
+
static props = {
|
|
31507
|
+
figureId: String,
|
|
31508
|
+
definition: Object,
|
|
31509
|
+
canUpdateChart: Function,
|
|
31510
|
+
updateChart: Function,
|
|
31511
|
+
};
|
|
31511
31512
|
state = owl.useState({ index: 0 });
|
|
31512
31513
|
get axesList() {
|
|
31513
31514
|
const { useLeftAxis, useRightAxis } = getDefinedAxis(this.props.definition);
|
|
@@ -31689,14 +31690,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31689
31690
|
const cancelledReasons = [...(this.state.sectionRuleDispatchResult?.reasons || [])];
|
|
31690
31691
|
return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
|
|
31691
31692
|
}
|
|
31692
|
-
updateBackgroundColor(color) {
|
|
31693
|
-
this.props.updateChart(this.props.figureId, {
|
|
31694
|
-
background: color,
|
|
31695
|
-
});
|
|
31696
|
-
}
|
|
31697
|
-
updateTitle(content) {
|
|
31698
|
-
this.props.updateChart(this.props.figureId, { title: { text: content } });
|
|
31699
|
-
}
|
|
31700
31693
|
isRangeMinInvalid() {
|
|
31701
31694
|
return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause("EmptyGaugeRangeMin" /* CommandResult.EmptyGaugeRangeMin */) ||
|
|
31702
31695
|
this.state.sectionRuleDispatchResult?.isCancelledBecause("GaugeRangeMinNaN" /* CommandResult.GaugeRangeMinNaN */) ||
|
|
@@ -31736,9 +31729,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31736
31729
|
sectionRule,
|
|
31737
31730
|
});
|
|
31738
31731
|
}
|
|
31739
|
-
get backgroundColorTitle() {
|
|
31740
|
-
return ChartTerms.BackgroundColor;
|
|
31741
|
-
}
|
|
31742
31732
|
}
|
|
31743
31733
|
|
|
31744
31734
|
class LineConfigPanel extends GenericChartConfigPanel {
|
|
@@ -31921,9 +31911,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31921
31911
|
get humanizeNumbersLabel() {
|
|
31922
31912
|
return _t("Humanize numbers");
|
|
31923
31913
|
}
|
|
31924
|
-
updateTitle(content) {
|
|
31925
|
-
this.props.updateChart(this.props.figureId, { title: { text: content } });
|
|
31926
|
-
}
|
|
31927
31914
|
updateHumanizeNumbers(humanize) {
|
|
31928
31915
|
this.props.updateChart(this.props.figureId, { humanize });
|
|
31929
31916
|
}
|
|
@@ -31946,9 +31933,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31946
31933
|
break;
|
|
31947
31934
|
}
|
|
31948
31935
|
}
|
|
31949
|
-
get backgroundColorTitle() {
|
|
31950
|
-
return ChartTerms.BackgroundColor;
|
|
31951
|
-
}
|
|
31952
31936
|
}
|
|
31953
31937
|
|
|
31954
31938
|
class WaterfallChartDesignPanel extends owl.Component {
|
|
@@ -33452,13 +33436,17 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
33452
33436
|
class: { type: String, optional: true },
|
|
33453
33437
|
};
|
|
33454
33438
|
static components = { Menu };
|
|
33439
|
+
menuId = new UuidGenerator().uuidv4();
|
|
33455
33440
|
selectRef = owl.useRef("select");
|
|
33456
33441
|
selectRect = useAbsoluteBoundingRect(this.selectRef);
|
|
33457
33442
|
state = owl.useState({
|
|
33458
33443
|
isMenuOpen: false,
|
|
33459
33444
|
});
|
|
33460
|
-
onClick() {
|
|
33461
|
-
this.
|
|
33445
|
+
onClick(ev) {
|
|
33446
|
+
if (ev.closedMenuId === this.menuId) {
|
|
33447
|
+
return;
|
|
33448
|
+
}
|
|
33449
|
+
this.state.isMenuOpen = !this.state.isMenuOpen;
|
|
33462
33450
|
}
|
|
33463
33451
|
onMenuClosed() {
|
|
33464
33452
|
this.state.isMenuOpen = false;
|
|
@@ -33466,7 +33454,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
33466
33454
|
get menuPosition() {
|
|
33467
33455
|
return {
|
|
33468
33456
|
x: this.selectRect.x,
|
|
33469
|
-
y: this.selectRect.y,
|
|
33457
|
+
y: this.selectRect.y + this.selectRect.height,
|
|
33470
33458
|
};
|
|
33471
33459
|
}
|
|
33472
33460
|
}
|
|
@@ -34406,9 +34394,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34406
34394
|
static props = {
|
|
34407
34395
|
onCloseSidePanel: Function,
|
|
34408
34396
|
};
|
|
34409
|
-
dataRange = "";
|
|
34410
34397
|
searchInput = owl.useRef("searchInput");
|
|
34411
34398
|
store;
|
|
34399
|
+
state;
|
|
34412
34400
|
get hasSearchResult() {
|
|
34413
34401
|
return this.store.selectedMatchIndex !== null;
|
|
34414
34402
|
}
|
|
@@ -34438,6 +34426,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34438
34426
|
}
|
|
34439
34427
|
setup() {
|
|
34440
34428
|
this.store = useLocalStore(FindAndReplaceStore);
|
|
34429
|
+
this.state = owl.useState({ dataRange: "" });
|
|
34441
34430
|
owl.onMounted(() => this.searchInput.el?.focus());
|
|
34442
34431
|
}
|
|
34443
34432
|
onFocusSearch() {
|
|
@@ -34474,13 +34463,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34474
34463
|
this.store.updateSearchOptions({ searchScope });
|
|
34475
34464
|
}
|
|
34476
34465
|
onSearchRangeChanged(ranges) {
|
|
34477
|
-
this.dataRange = ranges[0];
|
|
34466
|
+
this.state.dataRange = ranges[0];
|
|
34478
34467
|
}
|
|
34479
34468
|
updateDataRange() {
|
|
34480
|
-
if (!this.dataRange || this.searchOptions.searchScope !== "specificRange") {
|
|
34469
|
+
if (!this.state.dataRange || this.searchOptions.searchScope !== "specificRange") {
|
|
34481
34470
|
return;
|
|
34482
34471
|
}
|
|
34483
|
-
const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.dataRange);
|
|
34472
|
+
const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
|
|
34484
34473
|
this.store.updateSearchOptions({ specificRange });
|
|
34485
34474
|
}
|
|
34486
34475
|
}
|
|
@@ -34525,31 +34514,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34525
34514
|
}
|
|
34526
34515
|
}
|
|
34527
34516
|
|
|
34528
|
-
/** @odoo-module */
|
|
34529
|
-
class EditableName extends owl.Component {
|
|
34530
|
-
static template = "o-spreadsheet-EditableName";
|
|
34531
|
-
static props = {
|
|
34532
|
-
name: String,
|
|
34533
|
-
displayName: String,
|
|
34534
|
-
onChanged: Function,
|
|
34535
|
-
};
|
|
34536
|
-
state;
|
|
34537
|
-
setup() {
|
|
34538
|
-
this.state = owl.useState({
|
|
34539
|
-
isEditing: false,
|
|
34540
|
-
name: "",
|
|
34541
|
-
});
|
|
34542
|
-
}
|
|
34543
|
-
rename() {
|
|
34544
|
-
this.state.isEditing = true;
|
|
34545
|
-
this.state.name = this.props.name;
|
|
34546
|
-
}
|
|
34547
|
-
save() {
|
|
34548
|
-
this.props.onChanged(this.state.name.trim());
|
|
34549
|
-
this.state.isEditing = false;
|
|
34550
|
-
}
|
|
34551
|
-
}
|
|
34552
|
-
|
|
34553
34517
|
css /* scss */ `
|
|
34554
34518
|
.pivot-defer-update {
|
|
34555
34519
|
min-height: 35px;
|
|
@@ -34915,6 +34879,135 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34915
34879
|
}
|
|
34916
34880
|
}
|
|
34917
34881
|
|
|
34882
|
+
css /* scss */ `
|
|
34883
|
+
.os-cog-wheel-menu-icon {
|
|
34884
|
+
cursor: pointer;
|
|
34885
|
+
}
|
|
34886
|
+
|
|
34887
|
+
.os-cog-wheel-menu {
|
|
34888
|
+
background: white;
|
|
34889
|
+
.btn-link {
|
|
34890
|
+
text-decoration: none;
|
|
34891
|
+
color: #017e84;
|
|
34892
|
+
font-weight: 500;
|
|
34893
|
+
&:hover {
|
|
34894
|
+
color: #01585c;
|
|
34895
|
+
}
|
|
34896
|
+
}
|
|
34897
|
+
}
|
|
34898
|
+
`;
|
|
34899
|
+
class CogWheelMenu extends owl.Component {
|
|
34900
|
+
static template = "o-spreadsheet-CogWheelMenu";
|
|
34901
|
+
static components = { Popover };
|
|
34902
|
+
static props = {
|
|
34903
|
+
items: Array,
|
|
34904
|
+
};
|
|
34905
|
+
buttonRef = owl.useRef("button");
|
|
34906
|
+
popover = owl.useState({ isOpen: false });
|
|
34907
|
+
setup() {
|
|
34908
|
+
owl.useExternalListener(window, "click", (ev) => {
|
|
34909
|
+
if (ev.target !== this.buttonRef.el) {
|
|
34910
|
+
this.popover.isOpen = false;
|
|
34911
|
+
}
|
|
34912
|
+
});
|
|
34913
|
+
}
|
|
34914
|
+
get popoverProps() {
|
|
34915
|
+
const { x, y, width, height } = this.buttonRef.el.getBoundingClientRect();
|
|
34916
|
+
return {
|
|
34917
|
+
anchorRect: { x, y, width, height },
|
|
34918
|
+
positioning: "BottomLeft",
|
|
34919
|
+
};
|
|
34920
|
+
}
|
|
34921
|
+
togglePopover() {
|
|
34922
|
+
this.popover.isOpen = !this.popover.isOpen;
|
|
34923
|
+
}
|
|
34924
|
+
}
|
|
34925
|
+
|
|
34926
|
+
/** @odoo-module */
|
|
34927
|
+
class EditableName extends owl.Component {
|
|
34928
|
+
static template = "o-spreadsheet-EditableName";
|
|
34929
|
+
static props = {
|
|
34930
|
+
name: String,
|
|
34931
|
+
displayName: String,
|
|
34932
|
+
onChanged: Function,
|
|
34933
|
+
};
|
|
34934
|
+
state;
|
|
34935
|
+
setup() {
|
|
34936
|
+
this.state = owl.useState({
|
|
34937
|
+
isEditing: false,
|
|
34938
|
+
name: "",
|
|
34939
|
+
});
|
|
34940
|
+
}
|
|
34941
|
+
rename() {
|
|
34942
|
+
this.state.isEditing = true;
|
|
34943
|
+
this.state.name = this.props.name;
|
|
34944
|
+
}
|
|
34945
|
+
save() {
|
|
34946
|
+
this.props.onChanged(this.state.name.trim());
|
|
34947
|
+
this.state.isEditing = false;
|
|
34948
|
+
}
|
|
34949
|
+
}
|
|
34950
|
+
|
|
34951
|
+
class PivotTitleSection extends owl.Component {
|
|
34952
|
+
static template = "o-spreadsheet-PivotTitleSection";
|
|
34953
|
+
static components = { CogWheelMenu, Section, EditableName };
|
|
34954
|
+
static props = {
|
|
34955
|
+
pivotId: String,
|
|
34956
|
+
};
|
|
34957
|
+
get cogWheelMenuItems() {
|
|
34958
|
+
return [
|
|
34959
|
+
{
|
|
34960
|
+
name: "Duplicate",
|
|
34961
|
+
icon: "fa-copy",
|
|
34962
|
+
onClick: () => this.duplicatePivot(),
|
|
34963
|
+
},
|
|
34964
|
+
{
|
|
34965
|
+
name: "Delete",
|
|
34966
|
+
icon: "fa-trash",
|
|
34967
|
+
onClick: () => this.delete(),
|
|
34968
|
+
},
|
|
34969
|
+
];
|
|
34970
|
+
}
|
|
34971
|
+
get name() {
|
|
34972
|
+
return this.env.model.getters.getPivotName(this.props.pivotId);
|
|
34973
|
+
}
|
|
34974
|
+
get displayName() {
|
|
34975
|
+
return this.env.model.getters.getPivotDisplayName(this.props.pivotId);
|
|
34976
|
+
}
|
|
34977
|
+
duplicatePivot() {
|
|
34978
|
+
const newPivotId = this.env.model.uuidGenerator.uuidv4();
|
|
34979
|
+
const result = this.env.model.dispatch("DUPLICATE_PIVOT", {
|
|
34980
|
+
pivotId: this.props.pivotId,
|
|
34981
|
+
newPivotId,
|
|
34982
|
+
});
|
|
34983
|
+
const text = result.isSuccessful ? _t("Pivot duplicated.") : _t("Pivot duplication failed");
|
|
34984
|
+
const type = result.isSuccessful ? "success" : "danger";
|
|
34985
|
+
this.env.notifyUser({
|
|
34986
|
+
text,
|
|
34987
|
+
sticky: false,
|
|
34988
|
+
type,
|
|
34989
|
+
});
|
|
34990
|
+
if (result.isSuccessful) {
|
|
34991
|
+
this.env.openSidePanel("PivotSidePanel", { pivotId: newPivotId });
|
|
34992
|
+
}
|
|
34993
|
+
}
|
|
34994
|
+
delete() {
|
|
34995
|
+
this.env.askConfirmation(_t("Are you sure you want to delete this pivot?"), () => {
|
|
34996
|
+
this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
|
|
34997
|
+
});
|
|
34998
|
+
}
|
|
34999
|
+
onNameChanged(name) {
|
|
35000
|
+
const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
|
|
35001
|
+
this.env.model.dispatch("UPDATE_PIVOT", {
|
|
35002
|
+
pivotId: this.props.pivotId,
|
|
35003
|
+
pivot: {
|
|
35004
|
+
...pivot,
|
|
35005
|
+
name,
|
|
35006
|
+
},
|
|
35007
|
+
});
|
|
35008
|
+
}
|
|
35009
|
+
}
|
|
35010
|
+
|
|
34918
35011
|
/**
|
|
34919
35012
|
* Represent a pivot runtime definition. A pivot runtime definition is a pivot
|
|
34920
35013
|
* definition that has been enriched to include the display name of its attributes
|
|
@@ -35219,7 +35312,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35219
35312
|
}
|
|
35220
35313
|
const row = rows[index];
|
|
35221
35314
|
const rowName = row.nameWithGranularity;
|
|
35222
|
-
const groups =
|
|
35315
|
+
const groups = groupPivotDataEntriesBy(dataEntries, row);
|
|
35223
35316
|
const orderedKeys = orderDataEntriesKeys(groups, row);
|
|
35224
35317
|
const pivotTableRows = [];
|
|
35225
35318
|
const _fields = fields.concat(rowName);
|
|
@@ -35249,7 +35342,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35249
35342
|
}
|
|
35250
35343
|
const column = columns[index];
|
|
35251
35344
|
const colName = columns[index].nameWithGranularity;
|
|
35252
|
-
const groups =
|
|
35345
|
+
const groups = groupPivotDataEntriesBy(dataEntries, column);
|
|
35253
35346
|
const orderedKeys = orderDataEntriesKeys(groups, columns[index]);
|
|
35254
35347
|
return orderedKeys.map((value) => {
|
|
35255
35348
|
return {
|
|
@@ -35347,7 +35440,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35347
35440
|
/**
|
|
35348
35441
|
* Group the dataEntries based on the given dimension
|
|
35349
35442
|
*/
|
|
35350
|
-
function
|
|
35443
|
+
function groupPivotDataEntriesBy(dataEntries, dimension) {
|
|
35351
35444
|
return Object.groupBy(dataEntries, keySelector(dimension));
|
|
35352
35445
|
}
|
|
35353
35446
|
/**
|
|
@@ -35397,7 +35490,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35397
35490
|
number = Math.floor(date.getMonth() / 3) + 1;
|
|
35398
35491
|
break;
|
|
35399
35492
|
case "month_number":
|
|
35400
|
-
number = date.getMonth();
|
|
35493
|
+
number = date.getMonth() + 1;
|
|
35401
35494
|
break;
|
|
35402
35495
|
case "iso_week_number":
|
|
35403
35496
|
number = date.getIsoWeek();
|
|
@@ -35409,7 +35502,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35409
35502
|
number = Math.floor(toNumber(value, locale));
|
|
35410
35503
|
break;
|
|
35411
35504
|
}
|
|
35412
|
-
MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = number;
|
|
35505
|
+
MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = toNormalizedPivotValue(dimension, number);
|
|
35413
35506
|
}
|
|
35414
35507
|
return MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`];
|
|
35415
35508
|
}
|
|
@@ -35555,7 +35648,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35555
35648
|
return this._definition;
|
|
35556
35649
|
}
|
|
35557
35650
|
isValid() {
|
|
35558
|
-
if (this.invalidRangeError || !this.
|
|
35651
|
+
if (this.invalidRangeError || !this.definition) {
|
|
35559
35652
|
return false;
|
|
35560
35653
|
}
|
|
35561
35654
|
for (const measure of this.definition.measures) {
|
|
@@ -35612,25 +35705,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35612
35705
|
const dimension = this.getDimension(lastNode.field);
|
|
35613
35706
|
const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
|
|
35614
35707
|
const finalCell = cells[0]?.[dimension.nameWithGranularity];
|
|
35708
|
+
if (dimension.type === "date") {
|
|
35709
|
+
const adapter = pivotTimeAdapter(dimension.granularity);
|
|
35710
|
+
return {
|
|
35711
|
+
value: adapter.toCellValue(toNormalizedPivotValue(dimension, lastNode.value)),
|
|
35712
|
+
format: adapter.getFormat(this.getters.getLocale()),
|
|
35713
|
+
};
|
|
35714
|
+
}
|
|
35615
35715
|
if (!finalCell) {
|
|
35616
35716
|
return { value: "" };
|
|
35617
35717
|
}
|
|
35618
35718
|
if (finalCell.value === null) {
|
|
35619
35719
|
return { value: _t("(Undefined)") };
|
|
35620
35720
|
}
|
|
35621
|
-
if (dimension.type === "date") {
|
|
35622
|
-
if (dimension.granularity === "day") {
|
|
35623
|
-
return {
|
|
35624
|
-
value: toNumber(finalCell.value, this.getters.getLocale()),
|
|
35625
|
-
format: this.getters.getLocale().dateFormat,
|
|
35626
|
-
};
|
|
35627
|
-
}
|
|
35628
|
-
if (dimension.granularity === "month_number") {
|
|
35629
|
-
return {
|
|
35630
|
-
value: MONTHS[toNumber(finalCell.value, this.getters.getLocale())].toString(),
|
|
35631
|
-
};
|
|
35632
|
-
}
|
|
35633
|
-
}
|
|
35634
35721
|
return {
|
|
35635
35722
|
value: finalCell.value,
|
|
35636
35723
|
format: finalCell.format,
|
|
@@ -35655,9 +35742,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35655
35742
|
format: operator.format(values[0]),
|
|
35656
35743
|
};
|
|
35657
35744
|
}
|
|
35658
|
-
getPossibleFieldValues(
|
|
35659
|
-
|
|
35660
|
-
|
|
35745
|
+
getPossibleFieldValues(dimension) {
|
|
35746
|
+
const values = [];
|
|
35747
|
+
for (const value in groupPivotDataEntriesBy(this.dataEntries, dimension)) {
|
|
35748
|
+
values.push({ value, label: "" });
|
|
35749
|
+
}
|
|
35750
|
+
return values;
|
|
35661
35751
|
}
|
|
35662
35752
|
getTableStructure() {
|
|
35663
35753
|
if (!this.isValid()) {
|
|
@@ -35677,7 +35767,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35677
35767
|
filterDataEntriesFromDomainNode(dataEntries, domain) {
|
|
35678
35768
|
const { field, value } = domain;
|
|
35679
35769
|
const dimension = this.getDimension(field);
|
|
35680
|
-
return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` ===
|
|
35770
|
+
return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` ===
|
|
35771
|
+
`${toNormalizedPivotValue(dimension, value)}`);
|
|
35681
35772
|
}
|
|
35682
35773
|
getDimension(nameWithGranularity) {
|
|
35683
35774
|
return this.definition.getDimension(nameWithGranularity);
|
|
@@ -35813,15 +35904,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35813
35904
|
|
|
35814
35905
|
class PivotSidePanelStore extends SpreadsheetStore {
|
|
35815
35906
|
pivotId;
|
|
35816
|
-
mutators = [
|
|
35817
|
-
|
|
35818
|
-
"deferUpdates",
|
|
35819
|
-
"applyUpdate",
|
|
35820
|
-
"discardPendingUpdate",
|
|
35821
|
-
"renamePivot",
|
|
35822
|
-
"update",
|
|
35823
|
-
];
|
|
35824
|
-
updatesAreDeferred = true;
|
|
35907
|
+
mutators = ["reset", "deferUpdates", "applyUpdate", "discardPendingUpdate", "update"];
|
|
35908
|
+
updatesAreDeferred = false;
|
|
35825
35909
|
draft = null;
|
|
35826
35910
|
constructor(get, pivotId) {
|
|
35827
35911
|
super(get);
|
|
@@ -35938,16 +36022,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35938
36022
|
discardPendingUpdate() {
|
|
35939
36023
|
this.draft = null;
|
|
35940
36024
|
}
|
|
35941
|
-
renamePivot(name) {
|
|
35942
|
-
const pivot = this.getters.getPivotCoreDefinition(this.pivotId);
|
|
35943
|
-
this.model.dispatch("UPDATE_PIVOT", {
|
|
35944
|
-
pivotId: this.pivotId,
|
|
35945
|
-
pivot: {
|
|
35946
|
-
...pivot,
|
|
35947
|
-
name,
|
|
35948
|
-
},
|
|
35949
|
-
});
|
|
35950
|
-
}
|
|
35951
36025
|
update(definitionUpdate) {
|
|
35952
36026
|
const coreDefinition = this.getters.getPivotCoreDefinition(this.pivotId);
|
|
35953
36027
|
const definition = { ...coreDefinition, ...this.draft, ...definitionUpdate };
|
|
@@ -36030,9 +36104,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36030
36104
|
PivotLayoutConfigurator,
|
|
36031
36105
|
Section,
|
|
36032
36106
|
SelectionInput,
|
|
36033
|
-
EditableName,
|
|
36034
36107
|
Checkbox,
|
|
36035
36108
|
PivotDeferUpdate,
|
|
36109
|
+
PivotTitleSection,
|
|
36036
36110
|
};
|
|
36037
36111
|
store;
|
|
36038
36112
|
state;
|
|
@@ -36061,12 +36135,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36061
36135
|
get pivot() {
|
|
36062
36136
|
return this.store.pivot;
|
|
36063
36137
|
}
|
|
36064
|
-
get name() {
|
|
36065
|
-
return this.env.model.getters.getPivotName(this.props.pivotId);
|
|
36066
|
-
}
|
|
36067
|
-
get displayName() {
|
|
36068
|
-
return this.env.model.getters.getPivotDisplayName(this.props.pivotId);
|
|
36069
|
-
}
|
|
36070
36138
|
get definition() {
|
|
36071
36139
|
return this.store.definition;
|
|
36072
36140
|
}
|
|
@@ -36090,35 +36158,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36090
36158
|
this.store.applyUpdate();
|
|
36091
36159
|
}
|
|
36092
36160
|
}
|
|
36093
|
-
duplicatePivot() {
|
|
36094
|
-
const newPivotId = this.env.model.uuidGenerator.uuidv4();
|
|
36095
|
-
const result = this.env.model.dispatch("DUPLICATE_PIVOT", {
|
|
36096
|
-
pivotId: this.props.pivotId,
|
|
36097
|
-
newPivotId,
|
|
36098
|
-
});
|
|
36099
|
-
const text = result.isSuccessful ? _t("Pivot duplicated.") : _t("Pivot duplication failed");
|
|
36100
|
-
const type = result.isSuccessful ? "success" : "danger";
|
|
36101
|
-
this.env.notifyUser({
|
|
36102
|
-
text,
|
|
36103
|
-
sticky: false,
|
|
36104
|
-
type,
|
|
36105
|
-
});
|
|
36106
|
-
if (result.isSuccessful) {
|
|
36107
|
-
this.env.openSidePanel("PivotSidePanel", { pivotId: newPivotId });
|
|
36108
|
-
}
|
|
36109
|
-
}
|
|
36110
|
-
onNameChanged(name) {
|
|
36111
|
-
this.store.renamePivot(name);
|
|
36112
|
-
}
|
|
36113
36161
|
onDimensionsUpdated(definition) {
|
|
36114
36162
|
this.store.update(definition);
|
|
36115
36163
|
}
|
|
36116
|
-
back() {
|
|
36117
|
-
this.env.openSidePanel("PivotSidePanel", {});
|
|
36118
|
-
}
|
|
36119
|
-
delete() {
|
|
36120
|
-
this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
|
|
36121
|
-
}
|
|
36122
36164
|
}
|
|
36123
36165
|
|
|
36124
36166
|
const pivotSidePanelRegistry = new Registry();
|
|
@@ -36126,44 +36168,17 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36126
36168
|
editor: PivotSpreadsheetSidePanel,
|
|
36127
36169
|
});
|
|
36128
36170
|
|
|
36129
|
-
css /* scss */ `
|
|
36130
|
-
.o_pivot_list_item {
|
|
36131
|
-
cursor: pointer;
|
|
36132
|
-
&:hover {
|
|
36133
|
-
background-color: #f1f3f4;
|
|
36134
|
-
}
|
|
36135
|
-
}
|
|
36136
|
-
`;
|
|
36137
|
-
class PivotListItem extends owl.Component {
|
|
36138
|
-
static template = "o-spreadsheet-PivotListItem";
|
|
36139
|
-
static props = { pivotId: String };
|
|
36140
|
-
setup() {
|
|
36141
|
-
const previewRef = owl.useRef("pivotListItem");
|
|
36142
|
-
useHighlightsOnHover(previewRef, this);
|
|
36143
|
-
}
|
|
36144
|
-
selectPivot() {
|
|
36145
|
-
this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
|
|
36146
|
-
}
|
|
36147
|
-
get highlights() {
|
|
36148
|
-
return getPivotHighlights(this.env.model.getters, this.props.pivotId);
|
|
36149
|
-
}
|
|
36150
|
-
}
|
|
36151
|
-
|
|
36152
36171
|
class PivotSidePanel extends owl.Component {
|
|
36153
36172
|
static template = "o-spreadsheet-PivotSidePanel";
|
|
36154
36173
|
static props = {
|
|
36155
|
-
pivotId:
|
|
36174
|
+
pivotId: String,
|
|
36156
36175
|
onCloseSidePanel: Function,
|
|
36157
36176
|
};
|
|
36158
36177
|
static components = {
|
|
36159
36178
|
PivotLayoutConfigurator,
|
|
36160
36179
|
Section,
|
|
36161
|
-
PivotListItem,
|
|
36162
36180
|
};
|
|
36163
36181
|
get sidePanelEditor() {
|
|
36164
|
-
if (!this.props.pivotId) {
|
|
36165
|
-
throw new Error("pivotId is required to call this function.");
|
|
36166
|
-
}
|
|
36167
36182
|
const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
|
|
36168
36183
|
if (!pivot) {
|
|
36169
36184
|
throw new Error("pivotId does not correspond to a pivot.");
|
|
@@ -36180,6 +36195,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36180
36195
|
class RemoveDuplicatesPanel extends owl.Component {
|
|
36181
36196
|
static template = "o-spreadsheet-RemoveDuplicatesPanel";
|
|
36182
36197
|
static components = { ValidationMessages, Section, Checkbox };
|
|
36198
|
+
static props = { onCloseSidePanel: Function };
|
|
36183
36199
|
state = owl.useState({
|
|
36184
36200
|
hasHeader: false,
|
|
36185
36201
|
columns: {},
|
|
@@ -37322,21 +37338,15 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
37322
37338
|
});
|
|
37323
37339
|
sidePanelRegistry.add("PivotSidePanel", {
|
|
37324
37340
|
title: (env, props) => {
|
|
37325
|
-
|
|
37326
|
-
return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
|
|
37327
|
-
}
|
|
37328
|
-
return _t("List of Pivots");
|
|
37341
|
+
return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
|
|
37329
37342
|
},
|
|
37330
37343
|
Body: PivotSidePanel,
|
|
37331
|
-
computeState: (getters,
|
|
37332
|
-
|
|
37333
|
-
|
|
37334
|
-
|
|
37335
|
-
|
|
37336
|
-
|
|
37337
|
-
pivotId = undefined;
|
|
37338
|
-
}
|
|
37339
|
-
return { isOpen: true, props: { pivotId }, key: `pivot_key_${pivotId}` };
|
|
37344
|
+
computeState: (getters, props) => {
|
|
37345
|
+
return {
|
|
37346
|
+
isOpen: getters.isExistingPivot(props.pivotId),
|
|
37347
|
+
props,
|
|
37348
|
+
key: `pivot_key_${props.pivotId}`,
|
|
37349
|
+
};
|
|
37340
37350
|
},
|
|
37341
37351
|
});
|
|
37342
37352
|
|
|
@@ -38604,7 +38614,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
38604
38614
|
});
|
|
38605
38615
|
}
|
|
38606
38616
|
getContainerRect(container) {
|
|
38607
|
-
const { width: viewWidth, height: viewHeight } = this.env.model.getters.
|
|
38617
|
+
const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
|
|
38608
38618
|
const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
|
|
38609
38619
|
const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
|
|
38610
38620
|
const width = viewWidth - x;
|
|
@@ -41594,133 +41604,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
41594
41604
|
}
|
|
41595
41605
|
}
|
|
41596
41606
|
|
|
41597
|
-
const pivotTimeAdapterRegistry = new Registry();
|
|
41598
|
-
function pivotTimeAdapter(granularity) {
|
|
41599
|
-
return pivotTimeAdapterRegistry.get(granularity);
|
|
41600
|
-
}
|
|
41601
|
-
/**
|
|
41602
|
-
* The Time Adapter: Managing Time Periods for Pivot Functions
|
|
41603
|
-
*
|
|
41604
|
-
* Overview:
|
|
41605
|
-
* A time adapter is responsible for managing time periods associated with pivot functions.
|
|
41606
|
-
* Each type of period (day, week, month, quarter, etc.) has its own dedicated adapter.
|
|
41607
|
-
* The adapter's primary role is to normalize period values between spreadsheet functions,
|
|
41608
|
-
* and the pivot.
|
|
41609
|
-
* By normalizing the period value, it can be stored consistently in the pivot.
|
|
41610
|
-
*
|
|
41611
|
-
* Normalization Process:
|
|
41612
|
-
* When working with functions in the spreadsheet, the time adapter normalizes
|
|
41613
|
-
* the provided period to facilitate accurate lookup of values in the pivot.
|
|
41614
|
-
* For instance, if the spreadsheet function represents a day period as a number generated
|
|
41615
|
-
* by the DATE function (DATE(2023, 12, 25)), the time adapter will normalize it accordingly.
|
|
41616
|
-
*
|
|
41617
|
-
*/
|
|
41618
|
-
/**
|
|
41619
|
-
* Normalized value: "12/25/2023"
|
|
41620
|
-
*
|
|
41621
|
-
* Note: Those two format are equivalent:
|
|
41622
|
-
* - "MM/dd/yyyy" (luxon format)
|
|
41623
|
-
* - "mm/dd/yyyy" (spreadsheet format)
|
|
41624
|
-
**/
|
|
41625
|
-
const dayAdapter = {
|
|
41626
|
-
normalizeFunctionValue(value) {
|
|
41627
|
-
const date = toNumber(value, DEFAULT_LOCALE);
|
|
41628
|
-
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/dd/yyyy" });
|
|
41629
|
-
},
|
|
41630
|
-
getFormat(locale) {
|
|
41631
|
-
return (locale ?? DEFAULT_LOCALE).dateFormat;
|
|
41632
|
-
},
|
|
41633
|
-
formatValue(normalizedValue, locale) {
|
|
41634
|
-
locale = locale ?? DEFAULT_LOCALE;
|
|
41635
|
-
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
41636
|
-
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
41637
|
-
},
|
|
41638
|
-
toCellValue(normalizedValue) {
|
|
41639
|
-
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
41640
|
-
},
|
|
41641
|
-
};
|
|
41642
|
-
/**
|
|
41643
|
-
* Normalized value: "2/2023" for week 2 of 2023
|
|
41644
|
-
*/
|
|
41645
|
-
const weekAdapter = {
|
|
41646
|
-
normalizeFunctionValue(value) {
|
|
41647
|
-
const [week, year] = value.split("/");
|
|
41648
|
-
return `${Number(week)}/${Number(year)}`;
|
|
41649
|
-
},
|
|
41650
|
-
getFormat() {
|
|
41651
|
-
return undefined;
|
|
41652
|
-
},
|
|
41653
|
-
formatValue(normalizedValue) {
|
|
41654
|
-
const [week, year] = normalizedValue.split("/");
|
|
41655
|
-
return _t("W%(week)s %(year)s", { week, year });
|
|
41656
|
-
},
|
|
41657
|
-
toCellValue(normalizedValue) {
|
|
41658
|
-
return this.formatValue(normalizedValue);
|
|
41659
|
-
},
|
|
41660
|
-
};
|
|
41661
|
-
/**
|
|
41662
|
-
* normalized month value is a string formatted as "MM/yyyy" (luxon format)
|
|
41663
|
-
* e.g. "01/2020" for January 2020
|
|
41664
|
-
*/
|
|
41665
|
-
const monthAdapter = {
|
|
41666
|
-
normalizeFunctionValue(value) {
|
|
41667
|
-
const date = toNumber(value, DEFAULT_LOCALE);
|
|
41668
|
-
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
|
|
41669
|
-
},
|
|
41670
|
-
getFormat() {
|
|
41671
|
-
return "mmmm yyyy";
|
|
41672
|
-
},
|
|
41673
|
-
formatValue(normalizedValue, locale) {
|
|
41674
|
-
locale = locale ?? DEFAULT_LOCALE;
|
|
41675
|
-
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
41676
|
-
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
41677
|
-
},
|
|
41678
|
-
toCellValue(normalizedValue) {
|
|
41679
|
-
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
41680
|
-
},
|
|
41681
|
-
};
|
|
41682
|
-
/**
|
|
41683
|
-
* normalized quarter value is "quarter/year"
|
|
41684
|
-
* e.g. "1/2020" for Q1 2020
|
|
41685
|
-
*/
|
|
41686
|
-
const quarterAdapter = {
|
|
41687
|
-
normalizeFunctionValue(value) {
|
|
41688
|
-
const [quarter, year] = value.split("/");
|
|
41689
|
-
return `${quarter}/${year}`;
|
|
41690
|
-
},
|
|
41691
|
-
getFormat() {
|
|
41692
|
-
return undefined;
|
|
41693
|
-
},
|
|
41694
|
-
formatValue(normalizedValue) {
|
|
41695
|
-
const [quarter, year] = normalizedValue.split("/");
|
|
41696
|
-
return _t("Q%(quarter)s %(year)s", { quarter, year });
|
|
41697
|
-
},
|
|
41698
|
-
toCellValue(normalizedValue) {
|
|
41699
|
-
return this.formatValue(normalizedValue);
|
|
41700
|
-
},
|
|
41701
|
-
};
|
|
41702
|
-
const yearAdapter = {
|
|
41703
|
-
normalizeFunctionValue(value) {
|
|
41704
|
-
return toNumber(value, DEFAULT_LOCALE);
|
|
41705
|
-
},
|
|
41706
|
-
getFormat() {
|
|
41707
|
-
return "0";
|
|
41708
|
-
},
|
|
41709
|
-
formatValue(normalizedValue, locale) {
|
|
41710
|
-
locale = locale ?? DEFAULT_LOCALE;
|
|
41711
|
-
return formatValue(normalizedValue, { locale, format: "0" });
|
|
41712
|
-
},
|
|
41713
|
-
toCellValue(normalizedValue) {
|
|
41714
|
-
return normalizedValue;
|
|
41715
|
-
},
|
|
41716
|
-
};
|
|
41717
|
-
pivotTimeAdapterRegistry
|
|
41718
|
-
.add("day", dayAdapter)
|
|
41719
|
-
.add("week", weekAdapter)
|
|
41720
|
-
.add("month", monthAdapter)
|
|
41721
|
-
.add("quarter", quarterAdapter)
|
|
41722
|
-
.add("year", yearAdapter);
|
|
41723
|
-
|
|
41724
41607
|
/**
|
|
41725
41608
|
* Represent a raw XML string
|
|
41726
41609
|
*/
|
|
@@ -46919,9 +46802,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
46919
46802
|
}
|
|
46920
46803
|
createLiteralCell(id, content, format, style) {
|
|
46921
46804
|
const locale = this.getters.getLocale();
|
|
46922
|
-
|
|
46805
|
+
const parsedValue = parseLiteral(content, locale);
|
|
46806
|
+
format =
|
|
46807
|
+
format ||
|
|
46808
|
+
(typeof parsedValue === "number"
|
|
46809
|
+
? detectDateFormat(content, locale) || detectNumberFormat(content)
|
|
46810
|
+
: undefined);
|
|
46923
46811
|
if (format !== PLAIN_TEXT_FORMAT && !isEvaluationError(content)) {
|
|
46924
|
-
content = toString(
|
|
46812
|
+
content = toString(parsedValue);
|
|
46925
46813
|
}
|
|
46926
46814
|
return {
|
|
46927
46815
|
id,
|
|
@@ -46929,6 +46817,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
46929
46817
|
style,
|
|
46930
46818
|
format,
|
|
46931
46819
|
isFormula: false,
|
|
46820
|
+
parsedValue,
|
|
46932
46821
|
};
|
|
46933
46822
|
}
|
|
46934
46823
|
createFormulaCell(id, content, format, style, sheetId) {
|
|
@@ -51226,22 +51115,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
51226
51115
|
this.addPivotFormula(cellPosition, formulaId, pivotCell);
|
|
51227
51116
|
}
|
|
51228
51117
|
}
|
|
51229
|
-
const pivotZone = {
|
|
51230
|
-
top: position.row,
|
|
51231
|
-
bottom: position.row + pivotCells[0].length - 1,
|
|
51232
|
-
left: position.col,
|
|
51233
|
-
right: position.col + pivotCells.length - 1,
|
|
51234
|
-
};
|
|
51235
|
-
const numberOfHeaders = table.columns.length - 1;
|
|
51236
|
-
const cmdContent = {
|
|
51237
|
-
sheetId: position.sheetId,
|
|
51238
|
-
ranges: [this.getters.getRangeDataFromZone(position.sheetId, pivotZone)],
|
|
51239
|
-
config: { ...PIVOT_TABLE_CONFIG, numberOfHeaders },
|
|
51240
|
-
tableType: "static",
|
|
51241
|
-
};
|
|
51242
|
-
if (this.canDispatch("CREATE_TABLE", cmdContent).isSuccessful) {
|
|
51243
|
-
this.dispatch("CREATE_TABLE", cmdContent);
|
|
51244
|
-
}
|
|
51245
51118
|
}
|
|
51246
51119
|
resizeSheet(sheetId, { col, row }, table) {
|
|
51247
51120
|
const colLimit = table.getNumberOfDataColumns() + 1; // +1 for the Top-Left
|
|
@@ -51671,6 +51544,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
51671
51544
|
get({ sheetId, col, row }) {
|
|
51672
51545
|
return this.map[sheetId]?.[col]?.[row];
|
|
51673
51546
|
}
|
|
51547
|
+
getSheet(sheetId) {
|
|
51548
|
+
return this.map[sheetId];
|
|
51549
|
+
}
|
|
51674
51550
|
has({ sheetId, col, row }) {
|
|
51675
51551
|
return this.map[sheetId]?.[col]?.[row] !== undefined;
|
|
51676
51552
|
}
|
|
@@ -51689,6 +51565,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
51689
51565
|
}
|
|
51690
51566
|
return keys;
|
|
51691
51567
|
}
|
|
51568
|
+
keysForSheet(sheetId) {
|
|
51569
|
+
const map = this.map[sheetId];
|
|
51570
|
+
if (!map) {
|
|
51571
|
+
return [];
|
|
51572
|
+
}
|
|
51573
|
+
const keys = [];
|
|
51574
|
+
for (const col in map) {
|
|
51575
|
+
for (const row in map[col]) {
|
|
51576
|
+
keys.push({ sheetId, col: parseInt(col), row: parseInt(row) });
|
|
51577
|
+
}
|
|
51578
|
+
}
|
|
51579
|
+
return keys;
|
|
51580
|
+
}
|
|
51692
51581
|
}
|
|
51693
51582
|
|
|
51694
51583
|
function quickselect(arr, k, left, right, compare) {
|
|
@@ -52767,6 +52656,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52767
52656
|
getEvaluatedPositions() {
|
|
52768
52657
|
return this.evaluatedCells.keys();
|
|
52769
52658
|
}
|
|
52659
|
+
getEvaluatedPositionsInSheet(sheetId) {
|
|
52660
|
+
return this.evaluatedCells.keysForSheet(sheetId);
|
|
52661
|
+
}
|
|
52770
52662
|
getArrayFormulaSpreadingOn(position) {
|
|
52771
52663
|
if (!this.spreadingRelations.hasArrayFormulaResult(position)) {
|
|
52772
52664
|
return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
|
|
@@ -52775,6 +52667,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52775
52667
|
return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
|
|
52776
52668
|
}
|
|
52777
52669
|
updateDependencies(position) {
|
|
52670
|
+
// removing dependencies is slow because it requires
|
|
52671
|
+
// to traverse the entire r-tree.
|
|
52672
|
+
// The data structure is optimized for searches the other way around
|
|
52778
52673
|
this.formulaDependencies().removeAllDependencies(position);
|
|
52779
52674
|
const dependencies = this.getDirectDependencies(position);
|
|
52780
52675
|
this.formulaDependencies().addDependencies(position, dependencies);
|
|
@@ -52940,7 +52835,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52940
52835
|
this.cellsBeingComputed.add(cellId);
|
|
52941
52836
|
return cell.isFormula
|
|
52942
52837
|
? this.computeFormulaCell(position.sheetId, cell)
|
|
52943
|
-
: evaluateLiteral(cell
|
|
52838
|
+
: evaluateLiteral(cell, localeFormat);
|
|
52944
52839
|
}
|
|
52945
52840
|
catch (e) {
|
|
52946
52841
|
e.value = e?.value || CellErrorType.GenericError;
|
|
@@ -53210,6 +53105,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
53210
53105
|
"getEvaluatedCell",
|
|
53211
53106
|
"getEvaluatedCells",
|
|
53212
53107
|
"getEvaluatedCellsInZone",
|
|
53108
|
+
"getEvaluatedCellsPositions",
|
|
53213
53109
|
"getSpreadZone",
|
|
53214
53110
|
"getArrayFormulaSpreadingOn",
|
|
53215
53111
|
"isEmpty",
|
|
@@ -53301,13 +53197,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
53301
53197
|
return this.evaluator.getEvaluatedCell(position);
|
|
53302
53198
|
}
|
|
53303
53199
|
getEvaluatedCells(sheetId) {
|
|
53304
|
-
|
|
53305
|
-
|
|
53306
|
-
|
|
53307
|
-
|
|
53308
|
-
|
|
53309
|
-
|
|
53310
|
-
return record;
|
|
53200
|
+
return this.evaluator
|
|
53201
|
+
.getEvaluatedPositionsInSheet(sheetId)
|
|
53202
|
+
.map((position) => this.getEvaluatedCell(position));
|
|
53203
|
+
}
|
|
53204
|
+
getEvaluatedCellsPositions(sheetId) {
|
|
53205
|
+
return this.evaluator.getEvaluatedPositionsInSheet(sheetId);
|
|
53311
53206
|
}
|
|
53312
53207
|
getEvaluatedCellsInZone(sheetId, zone) {
|
|
53313
53208
|
return positions(zone).map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId, col, row }));
|
|
@@ -55975,7 +55870,10 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
55975
55870
|
/**
|
|
55976
55871
|
* Notify the server that the user client left the collaborative session
|
|
55977
55872
|
*/
|
|
55978
|
-
leave() {
|
|
55873
|
+
leave(data) {
|
|
55874
|
+
if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
|
|
55875
|
+
this.snapshot(data);
|
|
55876
|
+
}
|
|
55979
55877
|
delete this.clients[this.clientId];
|
|
55980
55878
|
this.transportService.leave(this.clientId);
|
|
55981
55879
|
this.transportService.sendMessage({
|
|
@@ -55988,6 +55886,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
55988
55886
|
* Send a snapshot of the spreadsheet to the collaboration server
|
|
55989
55887
|
*/
|
|
55990
55888
|
snapshot(data) {
|
|
55889
|
+
if (this.pendingMessages.length !== 0) {
|
|
55890
|
+
return;
|
|
55891
|
+
}
|
|
55991
55892
|
const snapshotId = this.uuidGenerator.uuidv4();
|
|
55992
55893
|
this.transportService.sendMessage({
|
|
55993
55894
|
type: "SNAPSHOT",
|
|
@@ -56389,7 +56290,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
56389
56290
|
bottom: rowIndex,
|
|
56390
56291
|
}));
|
|
56391
56292
|
const handler = new CellClipboardHandler(this.getters, this.dispatch);
|
|
56392
|
-
const data = handler.copy(getClipboardDataPositions(rowsToKeep));
|
|
56293
|
+
const data = handler.copy(getClipboardDataPositions(sheetId, rowsToKeep));
|
|
56393
56294
|
if (!data) {
|
|
56394
56295
|
return;
|
|
56395
56296
|
}
|
|
@@ -56402,7 +56303,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
56402
56303
|
right: zone.left,
|
|
56403
56304
|
bottom: zone.top,
|
|
56404
56305
|
};
|
|
56405
|
-
handler.paste({ zones: [zonePasted] }, data, { isCutOperation: false });
|
|
56306
|
+
handler.paste({ zones: [zonePasted], sheetId }, data, { isCutOperation: false });
|
|
56406
56307
|
const remainingZone = {
|
|
56407
56308
|
left: zone.left,
|
|
56408
56309
|
top: zone.top - (hasHeader ? 1 : 0),
|
|
@@ -58276,12 +58177,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
58276
58177
|
}
|
|
58277
58178
|
let zone = undefined;
|
|
58278
58179
|
let selectedZones = [];
|
|
58180
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
58279
58181
|
let target = {
|
|
58182
|
+
sheetId,
|
|
58280
58183
|
zones,
|
|
58281
58184
|
};
|
|
58282
58185
|
const handlers = this.selectClipboardHandlers(copiedData);
|
|
58283
58186
|
for (const handler of handlers) {
|
|
58284
|
-
const currentTarget = handler.getPasteTarget(zones, copiedData, options);
|
|
58187
|
+
const currentTarget = handler.getPasteTarget(sheetId, zones, copiedData, options);
|
|
58285
58188
|
if (currentTarget.figureId) {
|
|
58286
58189
|
target.figureId = currentTarget.figureId;
|
|
58287
58190
|
}
|
|
@@ -58450,11 +58353,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
58450
58353
|
return { cut: [cut], paste: [paste] };
|
|
58451
58354
|
}
|
|
58452
58355
|
getClipboardData(zones) {
|
|
58356
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
58453
58357
|
const selectedFigureId = this.getters.getSelectedFigureId();
|
|
58454
58358
|
if (selectedFigureId) {
|
|
58455
|
-
return { figureId: selectedFigureId };
|
|
58359
|
+
return { figureId: selectedFigureId, sheetId };
|
|
58456
58360
|
}
|
|
58457
|
-
return getClipboardDataPositions(zones);
|
|
58361
|
+
return getClipboardDataPositions(sheetId, zones);
|
|
58458
58362
|
}
|
|
58459
58363
|
// ---------------------------------------------------------------------------
|
|
58460
58364
|
// Grid rendering
|
|
@@ -59120,8 +59024,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
59120
59024
|
bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
59121
59025
|
},
|
|
59122
59026
|
];
|
|
59027
|
+
const sheetId = this.getActiveSheetId();
|
|
59123
59028
|
const handler = new CellClipboardHandler(this.getters, this.dispatch);
|
|
59124
|
-
const data = handler.copy(getClipboardDataPositions(target));
|
|
59029
|
+
const data = handler.copy(getClipboardDataPositions(sheetId, target));
|
|
59125
59030
|
if (!data) {
|
|
59126
59031
|
return;
|
|
59127
59032
|
}
|
|
@@ -59134,7 +59039,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
59134
59039
|
bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
59135
59040
|
},
|
|
59136
59041
|
];
|
|
59137
|
-
handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
|
|
59042
|
+
handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
|
|
59138
59043
|
const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
|
|
59139
59044
|
let currentIndex = cmd.base;
|
|
59140
59045
|
for (const element of toRemove) {
|
|
@@ -66498,7 +66403,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66498
66403
|
this.session.join(this.config.client);
|
|
66499
66404
|
}
|
|
66500
66405
|
leaveSession() {
|
|
66501
|
-
this.session.leave();
|
|
66406
|
+
this.session.leave(this.exportData());
|
|
66502
66407
|
}
|
|
66503
66408
|
setupUiPlugin(Plugin) {
|
|
66504
66409
|
const plugin = new Plugin(this.uiPluginConfig);
|
|
@@ -66905,7 +66810,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66905
66810
|
pivotRegistry,
|
|
66906
66811
|
pivotTimeAdapterRegistry,
|
|
66907
66812
|
pivotSidePanelRegistry,
|
|
66908
|
-
|
|
66813
|
+
pivotNormalizationValueRegistry,
|
|
66814
|
+
supportedPivotPositionalFormulaRegistry,
|
|
66909
66815
|
};
|
|
66910
66816
|
const helpers = {
|
|
66911
66817
|
arg,
|
|
@@ -66914,6 +66820,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66914
66820
|
toJsDate,
|
|
66915
66821
|
toNumber,
|
|
66916
66822
|
toString,
|
|
66823
|
+
toNormalizedPivotValue,
|
|
66917
66824
|
toXC,
|
|
66918
66825
|
toZone,
|
|
66919
66826
|
toUnboundedZone,
|
|
@@ -67009,6 +66916,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
67009
66916
|
PivotLayoutConfigurator,
|
|
67010
66917
|
EditableName,
|
|
67011
66918
|
PivotDeferUpdate,
|
|
66919
|
+
PivotTitleSection,
|
|
66920
|
+
CogWheelMenu,
|
|
67012
66921
|
};
|
|
67013
66922
|
const hooks = {
|
|
67014
66923
|
useDragAndDropListItems,
|
|
@@ -67092,9 +67001,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
67092
67001
|
exports.tokenize = tokenize;
|
|
67093
67002
|
|
|
67094
67003
|
|
|
67095
|
-
__info__.version = "17.4.0-alpha.
|
|
67096
|
-
__info__.date = "2024-06-
|
|
67097
|
-
__info__.hash = "
|
|
67004
|
+
__info__.version = "17.4.0-alpha.5";
|
|
67005
|
+
__info__.date = "2024-06-14T10:01:40.605Z";
|
|
67006
|
+
__info__.hash = "9ceed96";
|
|
67098
67007
|
|
|
67099
67008
|
|
|
67100
67009
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|