@odoo/o-spreadsheet 17.4.0-alpha.3 → 17.4.0-alpha.4
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 +683 -755
- package/dist/o-spreadsheet.d.ts +197 -115
- package/dist/o-spreadsheet.esm.js +683 -755
- package/dist/o-spreadsheet.iife.js +683 -755
- package/dist/o-spreadsheet.iife.min.js +364 -355
- package/dist/o_spreadsheet.xml +37 -32
- 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.4
|
|
7
|
+
* @date 2024-06-12T14:00:22.046Z
|
|
8
|
+
* @hash cefb0e4
|
|
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
|
*/
|
|
@@ -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),
|
|
@@ -10989,6 +10984,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
10989
10984
|
if (types.some((t) => t.startsWith("RANGE"))) {
|
|
10990
10985
|
result.acceptMatrix = true;
|
|
10991
10986
|
}
|
|
10987
|
+
if (types.every((t) => t.startsWith("RANGE"))) {
|
|
10988
|
+
result.acceptMatrixOnly = true;
|
|
10989
|
+
}
|
|
10992
10990
|
return result;
|
|
10993
10991
|
}
|
|
10994
10992
|
/**
|
|
@@ -11243,7 +11241,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11243
11241
|
arg("rows (number)", _t("The number of rows in the constrained array.")),
|
|
11244
11242
|
arg("columns (number)", _t("The number of columns in the constrained array.")),
|
|
11245
11243
|
],
|
|
11246
|
-
returns: ["RANGE<ANY>"],
|
|
11247
11244
|
compute: function (array, rows, columns) {
|
|
11248
11245
|
const _array = toMatrix(array);
|
|
11249
11246
|
const _rowsArg = toInteger(rows?.value, this.locale);
|
|
@@ -11266,15 +11263,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11266
11263
|
arg("col_num (number, range<number>)", _t("The first column index of the columns to be returned.")),
|
|
11267
11264
|
arg("col_num2 (number, range<number>, repeating)", _t("The columns indexes of the columns to be returned.")),
|
|
11268
11265
|
],
|
|
11269
|
-
returns: ["RANGE<ANY>"],
|
|
11270
11266
|
compute: function (array, ...columns) {
|
|
11271
11267
|
const _array = toMatrix(array);
|
|
11272
11268
|
const _columns = flattenRowFirst(columns, (item) => toInteger(item?.value, this.locale));
|
|
11273
|
-
|
|
11269
|
+
const argOutOfRange = _columns.filter((col) => col === 0 || _array.length < Math.abs(col));
|
|
11270
|
+
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
11271
|
const result = Array(_columns.length);
|
|
11275
11272
|
for (let col = 0; col < _columns.length; col++) {
|
|
11276
|
-
|
|
11277
|
-
|
|
11273
|
+
if (_columns[col] > 0) {
|
|
11274
|
+
result[col] = _array[_columns[col] - 1]; // -1 because columns arguments are 1-indexed
|
|
11275
|
+
}
|
|
11276
|
+
else {
|
|
11277
|
+
result[col] = _array[_array.length + _columns[col]];
|
|
11278
|
+
}
|
|
11278
11279
|
}
|
|
11279
11280
|
return result;
|
|
11280
11281
|
},
|
|
@@ -11290,13 +11291,18 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11290
11291
|
arg("row_num (number, range<number>)", _t("The first row index of the rows to be returned.")),
|
|
11291
11292
|
arg("row_num2 (number, range<number>, repeating)", _t("The rows indexes of the rows to be returned.")),
|
|
11292
11293
|
],
|
|
11293
|
-
returns: ["RANGE<ANY>"],
|
|
11294
11294
|
compute: function (array, ...rows) {
|
|
11295
11295
|
const _array = toMatrix(array);
|
|
11296
11296
|
const _rows = flattenRowFirst(rows, (item) => toInteger(item?.value, this.locale));
|
|
11297
11297
|
const _nbColumns = _array.length;
|
|
11298
|
-
|
|
11299
|
-
|
|
11298
|
+
const argOutOfRange = _rows.filter((row) => row === 0 || _array[0].length < Math.abs(row));
|
|
11299
|
+
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(",")));
|
|
11300
|
+
return generateMatrix(_nbColumns, _rows.length, (col, row) => {
|
|
11301
|
+
if (_rows[row] > 0) {
|
|
11302
|
+
return _array[col][_rows[row] - 1]; // -1 because columns arguments are 1-indexed
|
|
11303
|
+
}
|
|
11304
|
+
return _array[col][_array[col].length + _rows[row]];
|
|
11305
|
+
});
|
|
11300
11306
|
},
|
|
11301
11307
|
isExported: true,
|
|
11302
11308
|
};
|
|
@@ -11311,7 +11317,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11311
11317
|
arg("columns (number, optional)", _t("The number of columns in the expanded array. If missing, columns will not be expanded.")),
|
|
11312
11318
|
arg("pad_with (any, default=0)", _t("The value with which to pad.")), // @compatibility: on Excel, pad with #N/A
|
|
11313
11319
|
],
|
|
11314
|
-
returns: ["RANGE<ANY>"],
|
|
11315
11320
|
compute: function (arg, rows, columns, padWith = { value: 0 } // TODO : Replace with #N/A errors once it's supported
|
|
11316
11321
|
) {
|
|
11317
11322
|
const _array = toMatrix(arg);
|
|
@@ -11332,7 +11337,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11332
11337
|
arg("range (any, range<any>)", _t("The first range to flatten.")),
|
|
11333
11338
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to flatten.")),
|
|
11334
11339
|
],
|
|
11335
|
-
returns: ["RANGE<ANY>"],
|
|
11336
11340
|
compute: function (...ranges) {
|
|
11337
11341
|
return [flattenRowFirst(ranges, (val) => (val === undefined ? { value: "" } : val))];
|
|
11338
11342
|
},
|
|
@@ -11347,7 +11351,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11347
11351
|
arg("data (range<number>)", _t("The array of ranges containing the values to be counted.")),
|
|
11348
11352
|
arg("classes (number, range<number>)", _t("The range containing the set of classes.")),
|
|
11349
11353
|
],
|
|
11350
|
-
returns: ["RANGE<NUMBER>"],
|
|
11351
11354
|
compute: function (data, classes) {
|
|
11352
11355
|
const _data = flattenRowFirst([data], (data) => data.value).filter((val) => typeof val === "number");
|
|
11353
11356
|
const _classes = flattenRowFirst([classes], (data) => data.value).filter((val) => typeof val === "number");
|
|
@@ -11395,7 +11398,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11395
11398
|
arg("range1 (any, range<any>)", _t("The first range to be appended.")),
|
|
11396
11399
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
|
|
11397
11400
|
],
|
|
11398
|
-
returns: ["RANGE<ANY>"],
|
|
11399
11401
|
compute: function (...ranges) {
|
|
11400
11402
|
const nbRows = Math.max(...ranges.map((r) => r?.[0]?.length ?? 0));
|
|
11401
11403
|
const result = [];
|
|
@@ -11422,7 +11424,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11422
11424
|
args: [
|
|
11423
11425
|
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
11426
|
],
|
|
11425
|
-
returns: ["NUMBER"],
|
|
11426
11427
|
compute: function (matrix) {
|
|
11427
11428
|
const _matrix = toNumberMatrix(matrix, "square_matrix");
|
|
11428
11429
|
assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
|
|
@@ -11438,7 +11439,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11438
11439
|
args: [
|
|
11439
11440
|
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
11441
|
],
|
|
11441
|
-
returns: ["RANGE<NUMBER>"],
|
|
11442
11442
|
compute: function (matrix) {
|
|
11443
11443
|
const _matrix = toNumberMatrix(matrix, "square_matrix");
|
|
11444
11444
|
assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
|
|
@@ -11459,7 +11459,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11459
11459
|
arg("matrix1 (number, range<number>)", _t("The first matrix in the matrix multiplication operation.")),
|
|
11460
11460
|
arg("matrix2 (number, range<number>)", _t("The second matrix in the matrix multiplication operation.")),
|
|
11461
11461
|
],
|
|
11462
|
-
returns: ["RANGE<NUMBER>"],
|
|
11463
11462
|
compute: function (matrix1, matrix2) {
|
|
11464
11463
|
const _matrix1 = toNumberMatrix(matrix1, "matrix1");
|
|
11465
11464
|
const _matrix2 = toNumberMatrix(matrix2, "matrix2");
|
|
@@ -11478,7 +11477,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11478
11477
|
arg("range1 (number, range<number>)", _t("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),
|
|
11479
11478
|
arg("range2 (number, range<number>, repeating)", _t("The other range whose entries will be multiplied with corresponding entries in the other ranges.")),
|
|
11480
11479
|
],
|
|
11481
|
-
returns: ["NUMBER"],
|
|
11482
11480
|
compute: function (...args) {
|
|
11483
11481
|
assertSameDimensions(_t("All the ranges must have the same dimensions."), ...args);
|
|
11484
11482
|
const _args = args.map(toMatrix);
|
|
@@ -11535,7 +11533,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11535
11533
|
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
11534
|
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
11535
|
],
|
|
11538
|
-
returns: ["NUMBER"],
|
|
11539
11536
|
compute: function (arrayX, arrayY) {
|
|
11540
11537
|
return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 - y ** 2);
|
|
11541
11538
|
},
|
|
@@ -11550,7 +11547,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11550
11547
|
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
11548
|
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
11549
|
],
|
|
11553
|
-
returns: ["NUMBER"],
|
|
11554
11550
|
compute: function (arrayX, arrayY) {
|
|
11555
11551
|
return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 + y ** 2);
|
|
11556
11552
|
},
|
|
@@ -11565,7 +11561,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11565
11561
|
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
11562
|
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
11563
|
],
|
|
11568
|
-
returns: ["NUMBER"],
|
|
11569
11564
|
compute: function (arrayX, arrayY) {
|
|
11570
11565
|
return getSumXAndY(arrayX, arrayY, (x, y) => (x - y) ** 2);
|
|
11571
11566
|
},
|
|
@@ -11601,7 +11596,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11601
11596
|
const TOCOL = {
|
|
11602
11597
|
description: _t("Transforms a range of cells into a single column."),
|
|
11603
11598
|
args: TO_COL_ROW_ARGS,
|
|
11604
|
-
returns: ["RANGE<ANY>"],
|
|
11605
11599
|
compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
|
|
11606
11600
|
const _array = toMatrix(array);
|
|
11607
11601
|
const _ignore = toNumber(ignore.value, this.locale);
|
|
@@ -11622,7 +11616,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11622
11616
|
const TOROW = {
|
|
11623
11617
|
description: _t("Transforms a range of cells into a single row."),
|
|
11624
11618
|
args: TO_COL_ROW_ARGS,
|
|
11625
|
-
returns: ["RANGE<ANY>"],
|
|
11626
11619
|
compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
|
|
11627
11620
|
const _array = toMatrix(array);
|
|
11628
11621
|
const _ignore = toNumber(ignore.value, this.locale);
|
|
@@ -11644,7 +11637,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11644
11637
|
const TRANSPOSE = {
|
|
11645
11638
|
description: _t("Transposes the rows and columns of a range."),
|
|
11646
11639
|
args: [arg("range (any, range<any>)", _t("The range to be transposed."))],
|
|
11647
|
-
returns: ["RANGE"],
|
|
11648
11640
|
compute: function (arg) {
|
|
11649
11641
|
const _array = toMatrix(arg);
|
|
11650
11642
|
const nbColumns = _array[0].length;
|
|
@@ -11662,7 +11654,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11662
11654
|
arg("range1 (any, range<any>)", _t("The first range to be appended.")),
|
|
11663
11655
|
arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
|
|
11664
11656
|
],
|
|
11665
|
-
returns: ["RANGE<ANY>"],
|
|
11666
11657
|
compute: function (...ranges) {
|
|
11667
11658
|
const nbColumns = Math.max(...ranges.map((range) => toMatrix(range).length));
|
|
11668
11659
|
const nbRows = ranges.reduce((acc, range) => acc + toMatrix(range)[0].length, 0);
|
|
@@ -11694,7 +11685,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11694
11685
|
arg("pad_with (any, default=0)", // TODO : replace with #N/A
|
|
11695
11686
|
_t("The value with which to fill the extra cells in the range.")),
|
|
11696
11687
|
],
|
|
11697
|
-
returns: ["RANGE<ANY>"],
|
|
11698
11688
|
compute: function (range, wrapCount, padWith = { value: 0 }) {
|
|
11699
11689
|
const _array = toMatrix(range);
|
|
11700
11690
|
const nbRows = toInteger(wrapCount?.value, this.locale);
|
|
@@ -11719,7 +11709,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11719
11709
|
arg("pad_with (any, default=0)", // TODO : replace with #N/A
|
|
11720
11710
|
_t("The value with which to fill the extra cells in the range.")),
|
|
11721
11711
|
],
|
|
11722
|
-
returns: ["RANGE<ANY>"],
|
|
11723
11712
|
compute: function (range, wrapCount, padWith = { value: 0 }) {
|
|
11724
11713
|
const _array = toMatrix(range);
|
|
11725
11714
|
const nbColumns = toInteger(wrapCount?.value, this.locale);
|
|
@@ -11767,7 +11756,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11767
11756
|
arg("value (number)", _t("The number.")),
|
|
11768
11757
|
arg("unit (string, optional)", _t("The formatting unit. Use 'k', 'm', or 'b' to force the unit")),
|
|
11769
11758
|
],
|
|
11770
|
-
returns: ["NUMBER"],
|
|
11771
11759
|
compute: function (value, unite) {
|
|
11772
11760
|
return {
|
|
11773
11761
|
value: toNumber(value, this.locale),
|
|
@@ -11799,7 +11787,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11799
11787
|
const ABS = {
|
|
11800
11788
|
description: _t("Absolute value of a number."),
|
|
11801
11789
|
args: [arg("value (number)", _t("The number of which to return the absolute value."))],
|
|
11802
|
-
returns: ["NUMBER"],
|
|
11803
11790
|
compute: function (value) {
|
|
11804
11791
|
return Math.abs(toNumber(value, this.locale));
|
|
11805
11792
|
},
|
|
@@ -11813,7 +11800,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11813
11800
|
args: [
|
|
11814
11801
|
arg("value (number)", _t("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")),
|
|
11815
11802
|
],
|
|
11816
|
-
returns: ["NUMBER"],
|
|
11817
11803
|
compute: function (value) {
|
|
11818
11804
|
const _value = toNumber(value, this.locale);
|
|
11819
11805
|
assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11829,7 +11815,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11829
11815
|
args: [
|
|
11830
11816
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")),
|
|
11831
11817
|
],
|
|
11832
|
-
returns: ["NUMBER"],
|
|
11833
11818
|
compute: function (value) {
|
|
11834
11819
|
const _value = toNumber(value, this.locale);
|
|
11835
11820
|
assert(() => _value >= 1, _t("The value (%s) must be greater than or equal to 1.", _value.toString()));
|
|
@@ -11843,7 +11828,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11843
11828
|
const ACOT = {
|
|
11844
11829
|
description: _t("Inverse cotangent of a value."),
|
|
11845
11830
|
args: [arg("value (number)", _t("The value for which to calculate the inverse cotangent."))],
|
|
11846
|
-
returns: ["NUMBER"],
|
|
11847
11831
|
compute: function (value) {
|
|
11848
11832
|
const _value = toNumber(value, this.locale);
|
|
11849
11833
|
const sign = Math.sign(_value) || 1;
|
|
@@ -11862,7 +11846,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11862
11846
|
args: [
|
|
11863
11847
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")),
|
|
11864
11848
|
],
|
|
11865
|
-
returns: ["NUMBER"],
|
|
11866
11849
|
compute: function (value) {
|
|
11867
11850
|
const _value = toNumber(value, this.locale);
|
|
11868
11851
|
assert(() => Math.abs(_value) > 1, _t("The value (%s) cannot be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11878,7 +11861,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11878
11861
|
args: [
|
|
11879
11862
|
arg("value (number)", _t("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")),
|
|
11880
11863
|
],
|
|
11881
|
-
returns: ["NUMBER"],
|
|
11882
11864
|
compute: function (value) {
|
|
11883
11865
|
const _value = toNumber(value, this.locale);
|
|
11884
11866
|
assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
|
|
@@ -11894,7 +11876,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11894
11876
|
args: [
|
|
11895
11877
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic sine.")),
|
|
11896
11878
|
],
|
|
11897
|
-
returns: ["NUMBER"],
|
|
11898
11879
|
compute: function (value) {
|
|
11899
11880
|
return Math.asinh(toNumber(value, this.locale));
|
|
11900
11881
|
},
|
|
@@ -11906,7 +11887,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11906
11887
|
const ATAN = {
|
|
11907
11888
|
description: _t("Inverse tangent of a value, in radians."),
|
|
11908
11889
|
args: [arg("value (number)", _t("The value for which to calculate the inverse tangent."))],
|
|
11909
|
-
returns: ["NUMBER"],
|
|
11910
11890
|
compute: function (value) {
|
|
11911
11891
|
return Math.atan(toNumber(value, this.locale));
|
|
11912
11892
|
},
|
|
@@ -11921,7 +11901,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11921
11901
|
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
11902
|
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
11903
|
],
|
|
11924
|
-
returns: ["NUMBER"],
|
|
11925
11904
|
compute: function (x, y) {
|
|
11926
11905
|
const _x = toNumber(x, this.locale);
|
|
11927
11906
|
const _y = toNumber(y, this.locale);
|
|
@@ -11938,7 +11917,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11938
11917
|
args: [
|
|
11939
11918
|
arg("value (number)", _t("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")),
|
|
11940
11919
|
],
|
|
11941
|
-
returns: ["NUMBER"],
|
|
11942
11920
|
compute: function (value) {
|
|
11943
11921
|
const _value = toNumber(value, this.locale);
|
|
11944
11922
|
assert(() => Math.abs(_value) < 1, _t("The value (%s) must be between -1 and 1 exclusive.", _value.toString()));
|
|
@@ -11955,7 +11933,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11955
11933
|
arg("value (number)", _t("The value to round up to the nearest integer multiple of factor.")),
|
|
11956
11934
|
arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
|
|
11957
11935
|
],
|
|
11958
|
-
returns: ["NUMBER"],
|
|
11959
11936
|
compute: function (value, factor = { value: DEFAULT_FACTOR }) {
|
|
11960
11937
|
const _value = toNumber(value, this.locale);
|
|
11961
11938
|
const _factor = toNumber(factor, this.locale);
|
|
@@ -11990,7 +11967,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
11990
11967
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
|
|
11991
11968
|
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
11969
|
],
|
|
11993
|
-
returns: ["NUMBER"],
|
|
11994
11970
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
|
|
11995
11971
|
const _significance = toNumber(significance, this.locale);
|
|
11996
11972
|
const _number = toNumber(number, this.locale);
|
|
@@ -12011,7 +11987,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12011
11987
|
arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
|
|
12012
11988
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12013
11989
|
],
|
|
12014
|
-
returns: ["NUMBER"],
|
|
12015
11990
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12016
11991
|
const _significance = toNumber(significance, this.locale);
|
|
12017
11992
|
const _number = toNumber(number, this.locale);
|
|
@@ -12028,7 +12003,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12028
12003
|
const COS = {
|
|
12029
12004
|
description: _t("Cosine of an angle provided in radians."),
|
|
12030
12005
|
args: [arg("angle (number)", _t("The angle to find the cosine of, in radians."))],
|
|
12031
|
-
returns: ["NUMBER"],
|
|
12032
12006
|
compute: function (angle) {
|
|
12033
12007
|
return Math.cos(toNumber(angle, this.locale));
|
|
12034
12008
|
},
|
|
@@ -12040,7 +12014,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12040
12014
|
const COSH = {
|
|
12041
12015
|
description: _t("Hyperbolic cosine of any real number."),
|
|
12042
12016
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosine of."))],
|
|
12043
|
-
returns: ["NUMBER"],
|
|
12044
12017
|
compute: function (value) {
|
|
12045
12018
|
return Math.cosh(toNumber(value, this.locale));
|
|
12046
12019
|
},
|
|
@@ -12052,7 +12025,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12052
12025
|
const COT = {
|
|
12053
12026
|
description: _t("Cotangent of an angle provided in radians."),
|
|
12054
12027
|
args: [arg("angle (number)", _t("The angle to find the cotangent of, in radians."))],
|
|
12055
|
-
returns: ["NUMBER"],
|
|
12056
12028
|
compute: function (angle) {
|
|
12057
12029
|
const _angle = toNumber(angle, this.locale);
|
|
12058
12030
|
assertNotZero(_angle);
|
|
@@ -12066,7 +12038,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12066
12038
|
const COTH = {
|
|
12067
12039
|
description: _t("Hyperbolic cotangent of any real number."),
|
|
12068
12040
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cotangent of."))],
|
|
12069
|
-
returns: ["NUMBER"],
|
|
12070
12041
|
compute: function (value) {
|
|
12071
12042
|
const _value = toNumber(value, this.locale);
|
|
12072
12043
|
assertNotZero(_value);
|
|
@@ -12083,7 +12054,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12083
12054
|
arg("value1 (any, range)", _t("The first value or range in which to count the number of blanks.")),
|
|
12084
12055
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges in which to count the number of blanks.")),
|
|
12085
12056
|
],
|
|
12086
|
-
returns: ["NUMBER"],
|
|
12087
12057
|
compute: function (...args) {
|
|
12088
12058
|
return reduceAny(args, (acc, a) => {
|
|
12089
12059
|
if (a === undefined) {
|
|
@@ -12109,7 +12079,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12109
12079
|
arg("range (range)", _t("The range that is tested against criterion.")),
|
|
12110
12080
|
arg("criterion (string)", _t("The pattern or test to apply to range.")),
|
|
12111
12081
|
],
|
|
12112
|
-
returns: ["NUMBER"],
|
|
12113
12082
|
compute: function (...args) {
|
|
12114
12083
|
let count = 0;
|
|
12115
12084
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12130,7 +12099,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12130
12099
|
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
12100
|
arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
|
|
12132
12101
|
],
|
|
12133
|
-
returns: ["NUMBER"],
|
|
12134
12102
|
compute: function (...args) {
|
|
12135
12103
|
let count = 0;
|
|
12136
12104
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12149,7 +12117,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12149
12117
|
arg("value1 (any, range)", _t("The first value or range to consider for uniqueness.")),
|
|
12150
12118
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider for uniqueness.")),
|
|
12151
12119
|
],
|
|
12152
|
-
returns: ["NUMBER"],
|
|
12153
12120
|
compute: function (...args) {
|
|
12154
12121
|
return countUnique(args);
|
|
12155
12122
|
},
|
|
@@ -12166,7 +12133,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12166
12133
|
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
12134
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
12168
12135
|
],
|
|
12169
|
-
returns: ["NUMBER"],
|
|
12170
12136
|
compute: function (range, ...args) {
|
|
12171
12137
|
let uniqueValues = new Set();
|
|
12172
12138
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -12184,7 +12150,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12184
12150
|
const CSC = {
|
|
12185
12151
|
description: _t("Cosecant of an angle provided in radians."),
|
|
12186
12152
|
args: [arg("angle (number)", _t("The angle to find the cosecant of, in radians."))],
|
|
12187
|
-
returns: ["NUMBER"],
|
|
12188
12153
|
compute: function (angle) {
|
|
12189
12154
|
const _angle = toNumber(angle, this.locale);
|
|
12190
12155
|
assertNotZero(_angle);
|
|
@@ -12198,7 +12163,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12198
12163
|
const CSCH = {
|
|
12199
12164
|
description: _t("Hyperbolic cosecant of any real number."),
|
|
12200
12165
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosecant of."))],
|
|
12201
|
-
returns: ["NUMBER"],
|
|
12202
12166
|
compute: function (value) {
|
|
12203
12167
|
const _value = toNumber(value, this.locale);
|
|
12204
12168
|
assertNotZero(_value);
|
|
@@ -12215,7 +12179,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12215
12179
|
arg("value (string)", _t("The number to convert.")),
|
|
12216
12180
|
arg("base (number)", _t("The base to convert the value from.")),
|
|
12217
12181
|
],
|
|
12218
|
-
returns: ["NUMBER"],
|
|
12219
12182
|
compute: function (value, base) {
|
|
12220
12183
|
let _base = toNumber(base, this.locale);
|
|
12221
12184
|
_base = Math.floor(_base);
|
|
@@ -12242,7 +12205,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12242
12205
|
const DEGREES = {
|
|
12243
12206
|
description: _t("Converts an angle value in radians to degrees."),
|
|
12244
12207
|
args: [arg("angle (number)", _t("The angle to convert from radians to degrees."))],
|
|
12245
|
-
returns: ["NUMBER"],
|
|
12246
12208
|
compute: function (angle) {
|
|
12247
12209
|
return (toNumber(angle, this.locale) * 180) / Math.PI;
|
|
12248
12210
|
},
|
|
@@ -12254,7 +12216,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12254
12216
|
const EXP = {
|
|
12255
12217
|
description: _t("Euler's number, e (~2.718) raised to a power."),
|
|
12256
12218
|
args: [arg("value (number)", _t("The exponent to raise e."))],
|
|
12257
|
-
returns: ["NUMBER"],
|
|
12258
12219
|
compute: function (value) {
|
|
12259
12220
|
return Math.exp(toNumber(value, this.locale));
|
|
12260
12221
|
},
|
|
@@ -12269,7 +12230,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12269
12230
|
arg("value (number)", _t("The value to round down to the nearest integer multiple of factor.")),
|
|
12270
12231
|
arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
|
|
12271
12232
|
],
|
|
12272
|
-
returns: ["NUMBER"],
|
|
12273
12233
|
compute: function (value, factor = { value: DEFAULT_FACTOR }) {
|
|
12274
12234
|
const _value = toNumber(value, this.locale);
|
|
12275
12235
|
const _factor = toNumber(factor, this.locale);
|
|
@@ -12304,7 +12264,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12304
12264
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
|
|
12305
12265
|
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
12266
|
],
|
|
12307
|
-
returns: ["NUMBER"],
|
|
12308
12267
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
|
|
12309
12268
|
const _significance = toNumber(significance, this.locale);
|
|
12310
12269
|
const _number = toNumber(number, this.locale);
|
|
@@ -12325,7 +12284,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12325
12284
|
arg("number (number)", _t("The value to round down to the nearest integer multiple of significance.")),
|
|
12326
12285
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12327
12286
|
],
|
|
12328
|
-
returns: ["NUMBER"],
|
|
12329
12287
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12330
12288
|
const _significance = toNumber(significance, this.locale);
|
|
12331
12289
|
const _number = toNumber(number, this.locale);
|
|
@@ -12342,7 +12300,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12342
12300
|
const ISEVEN = {
|
|
12343
12301
|
description: _t("Whether the provided value is even."),
|
|
12344
12302
|
args: [arg("value (number)", _t("The value to be verified as even."))],
|
|
12345
|
-
returns: ["BOOLEAN"],
|
|
12346
12303
|
compute: function (value) {
|
|
12347
12304
|
const _value = strictToNumber(value, this.locale);
|
|
12348
12305
|
return Math.floor(Math.abs(_value)) & 1 ? false : true;
|
|
@@ -12358,7 +12315,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12358
12315
|
arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
|
|
12359
12316
|
arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
|
|
12360
12317
|
],
|
|
12361
|
-
returns: ["NUMBER"],
|
|
12362
12318
|
compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
|
|
12363
12319
|
const _number = toNumber(number, this.locale);
|
|
12364
12320
|
const _significance = toNumber(significance, this.locale);
|
|
@@ -12375,7 +12331,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12375
12331
|
const ISODD = {
|
|
12376
12332
|
description: _t("Whether the provided value is even."),
|
|
12377
12333
|
args: [arg("value (number)", _t("The value to be verified as even."))],
|
|
12378
|
-
returns: ["BOOLEAN"],
|
|
12379
12334
|
compute: function (value) {
|
|
12380
12335
|
const _value = strictToNumber(value, this.locale);
|
|
12381
12336
|
return Math.floor(Math.abs(_value)) & 1 ? true : false;
|
|
@@ -12388,7 +12343,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12388
12343
|
const LN = {
|
|
12389
12344
|
description: _t("The logarithm of a number, base e (euler's number)."),
|
|
12390
12345
|
args: [arg("value (number)", _t("The value for which to calculate the logarithm, base e."))],
|
|
12391
|
-
returns: ["NUMBER"],
|
|
12392
12346
|
compute: function (value) {
|
|
12393
12347
|
const _value = toNumber(value, this.locale);
|
|
12394
12348
|
assert(() => _value > 0, _t("The value (%s) must be strictly positive.", _value.toString()));
|
|
@@ -12414,7 +12368,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12414
12368
|
arg("dividend (number)", _t("The number to be divided to find the remainder.")),
|
|
12415
12369
|
arg("divisor (number)", _t("The number to divide by.")),
|
|
12416
12370
|
],
|
|
12417
|
-
returns: ["NUMBER"],
|
|
12418
12371
|
compute: function (dividend, divisor) {
|
|
12419
12372
|
const _divisor = toNumber(divisor, this.locale);
|
|
12420
12373
|
const _dividend = toNumber(dividend, this.locale);
|
|
@@ -12433,7 +12386,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12433
12386
|
args: [
|
|
12434
12387
|
arg("dimension (number)", _t("An integer specifying the dimension size of the unit matrix. It must be positive.")),
|
|
12435
12388
|
],
|
|
12436
|
-
returns: ["RANGE<NUMBER>"],
|
|
12437
12389
|
compute: function (n) {
|
|
12438
12390
|
const _n = toInteger(n, this.locale);
|
|
12439
12391
|
assertPositive(_t("The argument dimension must be positive"), _n);
|
|
@@ -12447,7 +12399,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12447
12399
|
const ODD = {
|
|
12448
12400
|
description: _t("Rounds a number up to the nearest odd integer."),
|
|
12449
12401
|
args: [arg("value (number)", _t("The value to round to the next greatest odd number."))],
|
|
12450
|
-
returns: ["NUMBER"],
|
|
12451
12402
|
compute: function (value) {
|
|
12452
12403
|
const _value = toNumber(value, this.locale);
|
|
12453
12404
|
let temp = Math.ceil(Math.abs(_value));
|
|
@@ -12465,7 +12416,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12465
12416
|
const PI = {
|
|
12466
12417
|
description: _t("The number pi."),
|
|
12467
12418
|
args: [],
|
|
12468
|
-
returns: ["NUMBER"],
|
|
12469
12419
|
compute: function () {
|
|
12470
12420
|
return Math.PI;
|
|
12471
12421
|
},
|
|
@@ -12480,7 +12430,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12480
12430
|
arg("base (number)", _t("The number to raise to the exponent power.")),
|
|
12481
12431
|
arg("exponent (number)", _t("The exponent to raise base to.")),
|
|
12482
12432
|
],
|
|
12483
|
-
returns: ["NUMBER"],
|
|
12484
12433
|
compute: function (base, exponent) {
|
|
12485
12434
|
const _base = toNumber(base, this.locale);
|
|
12486
12435
|
const _exponent = toNumber(exponent, this.locale);
|
|
@@ -12498,7 +12447,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12498
12447
|
arg("factor1 (number, range<number>)", _t("The first number or range to calculate for the product.")),
|
|
12499
12448
|
arg("factor2 (number, range<number>, repeating)", _t("More numbers or ranges to calculate for the product.")),
|
|
12500
12449
|
],
|
|
12501
|
-
returns: ["NUMBER"],
|
|
12502
12450
|
compute: function (...factors) {
|
|
12503
12451
|
let count = 0;
|
|
12504
12452
|
let acc = 1;
|
|
@@ -12535,7 +12483,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12535
12483
|
const RAND = {
|
|
12536
12484
|
description: _t("A random number between 0 inclusive and 1 exclusive."),
|
|
12537
12485
|
args: [],
|
|
12538
|
-
returns: ["NUMBER"],
|
|
12539
12486
|
compute: function () {
|
|
12540
12487
|
return Math.random();
|
|
12541
12488
|
},
|
|
@@ -12553,7 +12500,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12553
12500
|
arg("max (number, default=1)", _t("The maximum number you would like returned.")),
|
|
12554
12501
|
arg("whole_number (number, default=FALSE)", _t("Return a whole number or a decimal value.")),
|
|
12555
12502
|
],
|
|
12556
|
-
returns: ["RANGE<NUMBER>"],
|
|
12557
12503
|
compute: function (rows = { value: 1 }, columns = { value: 1 }, min = { value: 0 }, max = { value: 1 }, wholeNumber = { value: false }) {
|
|
12558
12504
|
const _cols = toInteger(columns, this.locale);
|
|
12559
12505
|
const _rows = toInteger(rows, this.locale);
|
|
@@ -12591,7 +12537,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12591
12537
|
arg("low (number)", _t("The low end of the random range.")),
|
|
12592
12538
|
arg("high (number)", _t("The high end of the random range.")),
|
|
12593
12539
|
],
|
|
12594
|
-
returns: ["NUMBER"],
|
|
12595
12540
|
compute: function (low, high) {
|
|
12596
12541
|
let _low = toNumber(low, this.locale);
|
|
12597
12542
|
if (!Number.isInteger(_low)) {
|
|
@@ -12618,7 +12563,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12618
12563
|
arg("value (number)", _t("The value to round to places number of places.")),
|
|
12619
12564
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12620
12565
|
],
|
|
12621
|
-
returns: ["NUMBER"],
|
|
12622
12566
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12623
12567
|
const _value = toNumber(value, this.locale);
|
|
12624
12568
|
let _places = toNumber(places, this.locale);
|
|
@@ -12649,7 +12593,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12649
12593
|
arg("value (number)", _t("The value to round to places number of places, always rounding down.")),
|
|
12650
12594
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12651
12595
|
],
|
|
12652
|
-
returns: ["NUMBER"],
|
|
12653
12596
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12654
12597
|
const _value = toNumber(value, this.locale);
|
|
12655
12598
|
let _places = toNumber(places, this.locale);
|
|
@@ -12680,7 +12623,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12680
12623
|
arg("value (number)", _t("The value to round to places number of places, always rounding up.")),
|
|
12681
12624
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
|
|
12682
12625
|
],
|
|
12683
|
-
returns: ["NUMBER"],
|
|
12684
12626
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12685
12627
|
const _value = toNumber(value, this.locale);
|
|
12686
12628
|
let _places = toNumber(places, this.locale);
|
|
@@ -12708,7 +12650,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12708
12650
|
const SEC = {
|
|
12709
12651
|
description: _t("Secant of an angle provided in radians."),
|
|
12710
12652
|
args: [arg("angle (number)", _t("The angle to find the secant of, in radians."))],
|
|
12711
|
-
returns: ["NUMBER"],
|
|
12712
12653
|
compute: function (angle) {
|
|
12713
12654
|
return 1 / Math.cos(toNumber(angle, this.locale));
|
|
12714
12655
|
},
|
|
@@ -12720,7 +12661,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12720
12661
|
const SECH = {
|
|
12721
12662
|
description: _t("Hyperbolic secant of any real number."),
|
|
12722
12663
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic secant of."))],
|
|
12723
|
-
returns: ["NUMBER"],
|
|
12724
12664
|
compute: function (value) {
|
|
12725
12665
|
return 1 / Math.cosh(toNumber(value, this.locale));
|
|
12726
12666
|
},
|
|
@@ -12732,7 +12672,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12732
12672
|
const SIN = {
|
|
12733
12673
|
description: _t("Sine of an angle provided in radians."),
|
|
12734
12674
|
args: [arg("angle (number)", _t("The angle to find the sine of, in radians."))],
|
|
12735
|
-
returns: ["NUMBER"],
|
|
12736
12675
|
compute: function (angle) {
|
|
12737
12676
|
return Math.sin(toNumber(angle, this.locale));
|
|
12738
12677
|
},
|
|
@@ -12744,7 +12683,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12744
12683
|
const SINH = {
|
|
12745
12684
|
description: _t("Hyperbolic sine of any real number."),
|
|
12746
12685
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic sine of."))],
|
|
12747
|
-
returns: ["NUMBER"],
|
|
12748
12686
|
compute: function (value) {
|
|
12749
12687
|
return Math.sinh(toNumber(value, this.locale));
|
|
12750
12688
|
},
|
|
@@ -12756,7 +12694,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12756
12694
|
const SQRT = {
|
|
12757
12695
|
description: _t("Positive square root of a positive number."),
|
|
12758
12696
|
args: [arg("value (number)", _t("The number for which to calculate the positive square root."))],
|
|
12759
|
-
returns: ["NUMBER"],
|
|
12760
12697
|
compute: function (value) {
|
|
12761
12698
|
const _value = toNumber(value, this.locale);
|
|
12762
12699
|
assert(() => _value >= 0, _t("The value (%s) must be positive or null.", _value.toString()));
|
|
@@ -12773,7 +12710,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12773
12710
|
arg("value1 (number, range<number>)", _t("The first number or range to add together.")),
|
|
12774
12711
|
arg("value2 (number, range<number>, repeating)", _t("Additional numbers or ranges to add to value1.")),
|
|
12775
12712
|
],
|
|
12776
|
-
returns: ["NUMBER"],
|
|
12777
12713
|
compute: function (...values) {
|
|
12778
12714
|
const v1 = values[0];
|
|
12779
12715
|
return {
|
|
@@ -12793,7 +12729,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12793
12729
|
arg("criterion (string)", _t("The pattern or test to apply to range.")),
|
|
12794
12730
|
arg("sum_range (range, default=criteria_range)", _t("The range to be summed, if different from range.")),
|
|
12795
12731
|
],
|
|
12796
|
-
returns: ["NUMBER"],
|
|
12797
12732
|
compute: function (criteriaRange, criterion, sumRange) {
|
|
12798
12733
|
if (sumRange === undefined) {
|
|
12799
12734
|
sumRange = criteriaRange;
|
|
@@ -12821,7 +12756,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12821
12756
|
arg("criteria_range2 (any, range, repeating)", _t("Additional ranges to check.")),
|
|
12822
12757
|
arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
|
|
12823
12758
|
],
|
|
12824
|
-
returns: ["NUMBER"],
|
|
12825
12759
|
compute: function (sumRange, ...criters) {
|
|
12826
12760
|
let sum = 0;
|
|
12827
12761
|
visitMatchingRanges(criters, (i, j) => {
|
|
@@ -12840,7 +12774,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12840
12774
|
const TAN = {
|
|
12841
12775
|
description: _t("Tangent of an angle provided in radians."),
|
|
12842
12776
|
args: [arg("angle (number)", _t("The angle to find the tangent of, in radians."))],
|
|
12843
|
-
returns: ["NUMBER"],
|
|
12844
12777
|
compute: function (angle) {
|
|
12845
12778
|
return Math.tan(toNumber(angle, this.locale));
|
|
12846
12779
|
},
|
|
@@ -12852,7 +12785,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12852
12785
|
const TANH = {
|
|
12853
12786
|
description: _t("Hyperbolic tangent of any real number."),
|
|
12854
12787
|
args: [arg("value (number)", _t("Any real value to calculate the hyperbolic tangent of."))],
|
|
12855
|
-
returns: ["NUMBER"],
|
|
12856
12788
|
compute: function (value) {
|
|
12857
12789
|
return Math.tanh(toNumber(value, this.locale));
|
|
12858
12790
|
},
|
|
@@ -12876,7 +12808,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12876
12808
|
arg("value (number)", _t("The value to be truncated.")),
|
|
12877
12809
|
arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of significant digits to the right of the decimal point to retain.")),
|
|
12878
12810
|
],
|
|
12879
|
-
returns: ["NUMBER"],
|
|
12880
12811
|
compute: function (value, places = { value: DEFAULT_PLACES }) {
|
|
12881
12812
|
const _value = toNumber(value, this.locale);
|
|
12882
12813
|
const _places = toNumber(places, this.locale);
|
|
@@ -12890,7 +12821,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
12890
12821
|
const INT = {
|
|
12891
12822
|
description: _t("Rounds a number down to the nearest integer that is less than or equal to it."),
|
|
12892
12823
|
args: [arg("value (number)", _t("The number to round down to the nearest integer."))],
|
|
12893
|
-
returns: ["NUMBER"],
|
|
12894
12824
|
compute: function (value) {
|
|
12895
12825
|
return Math.floor(toNumber(value, this.locale));
|
|
12896
12826
|
},
|
|
@@ -13249,7 +13179,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13249
13179
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
13250
13180
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
13251
13181
|
],
|
|
13252
|
-
returns: ["NUMBER"],
|
|
13253
13182
|
compute: function (...values) {
|
|
13254
13183
|
let count = 0;
|
|
13255
13184
|
const sum = reduceNumbers(values, (acc, a) => {
|
|
@@ -13271,7 +13200,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13271
13200
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
|
|
13272
13201
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
|
|
13273
13202
|
],
|
|
13274
|
-
returns: ["NUMBER"],
|
|
13275
13203
|
compute: function (...values) {
|
|
13276
13204
|
return {
|
|
13277
13205
|
value: average(values, this.locale),
|
|
@@ -13293,7 +13221,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13293
13221
|
arg("additional_values (number, range<number>, repeating)", _t("Additional values to average.")),
|
|
13294
13222
|
arg("additional_weights (number, range<number>, repeating)", _t("Additional weights.")),
|
|
13295
13223
|
],
|
|
13296
|
-
returns: ["NUMBER"],
|
|
13297
13224
|
compute: function (...args) {
|
|
13298
13225
|
let sum = 0;
|
|
13299
13226
|
let count = 0;
|
|
@@ -13341,7 +13268,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13341
13268
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
|
|
13342
13269
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
|
|
13343
13270
|
],
|
|
13344
|
-
returns: ["NUMBER"],
|
|
13345
13271
|
compute: function (...args) {
|
|
13346
13272
|
let count = 0;
|
|
13347
13273
|
const sum = reduceNumbersTextAs0(args, (acc, a) => {
|
|
@@ -13366,7 +13292,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13366
13292
|
arg("criterion (string)", _t("The pattern or test to apply to criteria_range.")),
|
|
13367
13293
|
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
13294
|
],
|
|
13369
|
-
returns: ["NUMBER"],
|
|
13370
13295
|
compute: function (criteriaRange, criterion, averageRange) {
|
|
13371
13296
|
const _averageRange = averageRange === undefined ? toMatrix(criteriaRange) : toMatrix(averageRange);
|
|
13372
13297
|
let count = 0;
|
|
@@ -13395,7 +13320,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13395
13320
|
arg("criteria_range2 (any, range, repeating)", _t("Additional criteria_range and criterion to check.")),
|
|
13396
13321
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13397
13322
|
],
|
|
13398
|
-
returns: ["NUMBER"],
|
|
13399
13323
|
compute: function (averageRange, ...args) {
|
|
13400
13324
|
const _averageRange = toMatrix(averageRange);
|
|
13401
13325
|
let count = 0;
|
|
@@ -13421,7 +13345,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13421
13345
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when counting.")),
|
|
13422
13346
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when counting.")),
|
|
13423
13347
|
],
|
|
13424
|
-
returns: ["NUMBER"],
|
|
13425
13348
|
compute: function (...values) {
|
|
13426
13349
|
return countNumbers(values, this.locale);
|
|
13427
13350
|
},
|
|
@@ -13436,7 +13359,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13436
13359
|
arg("value1 (any, range)", _t("The first value or range to consider when counting.")),
|
|
13437
13360
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when counting.")),
|
|
13438
13361
|
],
|
|
13439
|
-
returns: ["NUMBER"],
|
|
13440
13362
|
compute: function (...values) {
|
|
13441
13363
|
return countAny(values);
|
|
13442
13364
|
},
|
|
@@ -13453,7 +13375,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13453
13375
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13454
13376
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13455
13377
|
],
|
|
13456
|
-
returns: ["NUMBER"],
|
|
13457
13378
|
compute: function (dataY, dataX) {
|
|
13458
13379
|
return covariance(dataY, dataX, false);
|
|
13459
13380
|
},
|
|
@@ -13468,7 +13389,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13468
13389
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13469
13390
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13470
13391
|
],
|
|
13471
|
-
returns: ["NUMBER"],
|
|
13472
13392
|
compute: function (dataY, dataX) {
|
|
13473
13393
|
return covariance(dataY, dataX, false);
|
|
13474
13394
|
},
|
|
@@ -13483,7 +13403,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13483
13403
|
arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
|
|
13484
13404
|
arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
|
|
13485
13405
|
],
|
|
13486
|
-
returns: ["NUMBER"],
|
|
13487
13406
|
compute: function (dataY, dataX) {
|
|
13488
13407
|
return covariance(dataY, dataX, true);
|
|
13489
13408
|
},
|
|
@@ -13499,7 +13418,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13499
13418
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13500
13419
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13501
13420
|
],
|
|
13502
|
-
returns: ["NUMBER"],
|
|
13503
13421
|
compute: function (x, dataY, dataX) {
|
|
13504
13422
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13505
13423
|
return predictLinearValues([flatDataY], [flatDataX], matrixMap(toMatrix(x), (value) => toNumber(value, this.locale)), true);
|
|
@@ -13517,7 +13435,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13517
13435
|
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
13436
|
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
13437
|
],
|
|
13520
|
-
returns: ["NUMBER"],
|
|
13521
13438
|
compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
|
|
13522
13439
|
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
13440
|
},
|
|
@@ -13531,7 +13448,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13531
13448
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13532
13449
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13533
13450
|
],
|
|
13534
|
-
returns: ["NUMBER"],
|
|
13535
13451
|
compute: function (dataY, dataX) {
|
|
13536
13452
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13537
13453
|
const [[], [intercept]] = fullLinearRegression([flatDataX], [flatDataY]);
|
|
@@ -13548,7 +13464,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13548
13464
|
arg("data (any, range)", _t("Array or range containing the dataset to consider.")),
|
|
13549
13465
|
arg("n (number)", _t("The rank from largest to smallest of the element to return.")),
|
|
13550
13466
|
],
|
|
13551
|
-
returns: ["NUMBER"],
|
|
13552
13467
|
compute: function (data, n) {
|
|
13553
13468
|
const _n = Math.trunc(toNumber(n?.value, this.locale));
|
|
13554
13469
|
let largests = [];
|
|
@@ -13583,7 +13498,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13583
13498
|
arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
|
|
13584
13499
|
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
13500
|
],
|
|
13586
|
-
returns: ["NUMBER"],
|
|
13587
13501
|
compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
|
|
13588
13502
|
return fullLinearRegression(toNumberMatrix(dataX, "the first argument (data_y)"), toNumberMatrix(dataY, "the second argument (data_x)"), toBoolean(calculateB), toBoolean(verbose));
|
|
13589
13503
|
},
|
|
@@ -13600,7 +13514,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13600
13514
|
arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
|
|
13601
13515
|
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
13516
|
],
|
|
13603
|
-
returns: ["NUMBER"],
|
|
13604
13517
|
compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
|
|
13605
13518
|
const coeffs = fullLinearRegression(toNumberMatrix(dataX, "the second argument (data_x)"), logM(toNumberMatrix(dataY, "the first argument (data_y)")), toBoolean(calculateB), toBoolean(verbose));
|
|
13606
13519
|
for (let i = 0; i < coeffs.length; i++) {
|
|
@@ -13619,7 +13532,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13619
13532
|
arg("data_x (range)", _t("The range representing the array or matrix of observed data.")),
|
|
13620
13533
|
arg("data_y (range)", _t("The range representing the array or matrix of predicted data.")),
|
|
13621
13534
|
],
|
|
13622
|
-
returns: ["NUMBER"],
|
|
13623
13535
|
compute: function (dataX, dataY) {
|
|
13624
13536
|
const flatX = dataX.flat();
|
|
13625
13537
|
const flatY = dataY.flat();
|
|
@@ -13663,7 +13575,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13663
13575
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the maximum value.")),
|
|
13664
13576
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
|
|
13665
13577
|
],
|
|
13666
|
-
returns: ["NUMBER"],
|
|
13667
13578
|
compute: function (...values) {
|
|
13668
13579
|
return {
|
|
13669
13580
|
value: max(values, this.locale),
|
|
@@ -13681,7 +13592,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13681
13592
|
arg("value1 (any, range)", _t("The first value or range to consider when calculating the maximum value.")),
|
|
13682
13593
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
|
|
13683
13594
|
],
|
|
13684
|
-
returns: ["NUMBER"],
|
|
13685
13595
|
compute: function (...args) {
|
|
13686
13596
|
const maxa = reduceNumbersTextAs0(args, (acc, a) => {
|
|
13687
13597
|
return Math.max(a, acc);
|
|
@@ -13702,7 +13612,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13702
13612
|
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
13613
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13704
13614
|
],
|
|
13705
|
-
returns: ["NUMBER"],
|
|
13706
13615
|
compute: function (range, ...args) {
|
|
13707
13616
|
let result = -Infinity;
|
|
13708
13617
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -13724,7 +13633,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13724
13633
|
arg("value1 (any, range)", _t("The first value or range to consider when calculating the median value.")),
|
|
13725
13634
|
arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the median value.")),
|
|
13726
13635
|
],
|
|
13727
|
-
returns: ["NUMBER"],
|
|
13728
13636
|
compute: function (...values) {
|
|
13729
13637
|
let data = [];
|
|
13730
13638
|
visitNumbers(values, (value) => {
|
|
@@ -13746,7 +13654,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13746
13654
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
|
|
13747
13655
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
|
|
13748
13656
|
],
|
|
13749
|
-
returns: ["NUMBER"],
|
|
13750
13657
|
compute: function (...values) {
|
|
13751
13658
|
return {
|
|
13752
13659
|
value: min(values, this.locale),
|
|
@@ -13764,7 +13671,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13764
13671
|
arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
|
|
13765
13672
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
|
|
13766
13673
|
],
|
|
13767
|
-
returns: ["NUMBER"],
|
|
13768
13674
|
compute: function (...args) {
|
|
13769
13675
|
const mina = reduceNumbersTextAs0(args, (acc, a) => {
|
|
13770
13676
|
return Math.min(a, acc);
|
|
@@ -13785,7 +13691,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13785
13691
|
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
13692
|
arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
|
|
13787
13693
|
],
|
|
13788
|
-
returns: ["NUMBER"],
|
|
13789
13694
|
compute: function (range, ...args) {
|
|
13790
13695
|
let result = Infinity;
|
|
13791
13696
|
visitMatchingRanges(args, (i, j) => {
|
|
@@ -13828,7 +13733,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13828
13733
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
13829
13734
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
13830
13735
|
],
|
|
13831
|
-
returns: ["NUMBER"],
|
|
13832
13736
|
compute: function (dataY, dataX) {
|
|
13833
13737
|
return pearson(dataY, dataX);
|
|
13834
13738
|
},
|
|
@@ -13845,7 +13749,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13845
13749
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13846
13750
|
arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
|
|
13847
13751
|
],
|
|
13848
|
-
returns: ["NUMBER"],
|
|
13849
13752
|
compute: function (data, percentile) {
|
|
13850
13753
|
return PERCENTILE_INC.compute.bind(this)(data, percentile);
|
|
13851
13754
|
},
|
|
@@ -13860,7 +13763,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13860
13763
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13861
13764
|
arg("percentile (number)", _t("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")),
|
|
13862
13765
|
],
|
|
13863
|
-
returns: ["NUMBER"],
|
|
13864
13766
|
compute: function (data, percentile) {
|
|
13865
13767
|
return {
|
|
13866
13768
|
value: centile([data], percentile, false, this.locale),
|
|
@@ -13878,7 +13780,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13878
13780
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13879
13781
|
arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
|
|
13880
13782
|
],
|
|
13881
|
-
returns: ["NUMBER"],
|
|
13882
13783
|
compute: function (data, percentile) {
|
|
13883
13784
|
return {
|
|
13884
13785
|
value: centile([data], percentile, true, this.locale),
|
|
@@ -13898,7 +13799,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13898
13799
|
arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
|
|
13899
13800
|
arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
|
|
13900
13801
|
],
|
|
13901
|
-
returns: ["RANGE<NUMBER>"],
|
|
13902
13802
|
compute: function (dataY, dataX, order, intercept = { value: true }) {
|
|
13903
13803
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
13904
13804
|
return polynomialRegression(flatDataY, flatDataX, toNumber(order, this.locale), toBoolean(intercept));
|
|
@@ -13917,7 +13817,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13917
13817
|
arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
|
|
13918
13818
|
arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
|
|
13919
13819
|
],
|
|
13920
|
-
returns: ["NUMBER"],
|
|
13921
13820
|
compute: function (x, dataY, dataX, order, intercept = { value: true }) {
|
|
13922
13821
|
const _order = toNumber(order, this.locale);
|
|
13923
13822
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
@@ -13935,7 +13834,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13935
13834
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13936
13835
|
arg("quartile_number (number)", _t("Which quartile value to return.")),
|
|
13937
13836
|
],
|
|
13938
|
-
returns: ["NUMBER"],
|
|
13939
13837
|
compute: function (data, quartileNumber) {
|
|
13940
13838
|
return QUARTILE_INC.compute.bind(this)(data, quartileNumber);
|
|
13941
13839
|
},
|
|
@@ -13950,7 +13848,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13950
13848
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13951
13849
|
arg("quartile_number (number)", _t("Which quartile value, exclusive of 0 and 4, to return.")),
|
|
13952
13850
|
],
|
|
13953
|
-
returns: ["NUMBER"],
|
|
13954
13851
|
compute: function (data, quartileNumber) {
|
|
13955
13852
|
const _quartileNumber = Math.trunc(toNumber(quartileNumber, this.locale));
|
|
13956
13853
|
const percent = { value: 0.25 * _quartileNumber };
|
|
@@ -13970,7 +13867,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13970
13867
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
13971
13868
|
arg("quartile_number (number)", _t("Which quartile value to return.")),
|
|
13972
13869
|
],
|
|
13973
|
-
returns: ["NUMBER"],
|
|
13974
13870
|
compute: function (data, quartileNumber) {
|
|
13975
13871
|
const percent = { value: 0.25 * Math.trunc(toNumber(quartileNumber, this.locale)) };
|
|
13976
13872
|
return {
|
|
@@ -13989,7 +13885,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
13989
13885
|
arg("data (range)", _t("The range containing the dataset to consider.")),
|
|
13990
13886
|
arg("is_ascending (boolean, default=FALSE)", _t("Whether to consider the values in data in descending or ascending order.")),
|
|
13991
13887
|
],
|
|
13992
|
-
returns: ["ANY"],
|
|
13993
13888
|
compute: function (value, data, isAscending = { value: false }) {
|
|
13994
13889
|
const _isAscending = toBoolean(isAscending);
|
|
13995
13890
|
const _value = toNumber(value, this.locale);
|
|
@@ -14025,7 +13920,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14025
13920
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14026
13921
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14027
13922
|
],
|
|
14028
|
-
returns: ["NUMBER"],
|
|
14029
13923
|
compute: function (dataY, dataX) {
|
|
14030
13924
|
return Math.pow(pearson(dataX, dataY), 2.0);
|
|
14031
13925
|
},
|
|
@@ -14040,7 +13934,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14040
13934
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14041
13935
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14042
13936
|
],
|
|
14043
|
-
returns: ["NUMBER"],
|
|
14044
13937
|
compute: function (dataY, dataX) {
|
|
14045
13938
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14046
13939
|
const [[slope]] = fullLinearRegression([flatDataX], [flatDataY]);
|
|
@@ -14057,7 +13950,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14057
13950
|
arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
|
|
14058
13951
|
arg("n (number)", _t("The rank from smallest to largest of the element to return.")),
|
|
14059
13952
|
],
|
|
14060
|
-
returns: ["NUMBER"],
|
|
14061
13953
|
compute: function (data, n) {
|
|
14062
13954
|
const _n = Math.trunc(toNumber(n?.value, this.locale));
|
|
14063
13955
|
let largests = [];
|
|
@@ -14090,7 +13982,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14090
13982
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14091
13983
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14092
13984
|
],
|
|
14093
|
-
returns: ["NUMBER"],
|
|
14094
13985
|
compute: function (dataX, dataY) {
|
|
14095
13986
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14096
13987
|
const n = flatDataX.length;
|
|
@@ -14117,7 +14008,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14117
14008
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14118
14009
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14119
14010
|
],
|
|
14120
|
-
returns: ["NUMBER"],
|
|
14121
14011
|
compute: function (...args) {
|
|
14122
14012
|
return Math.sqrt(VAR.compute.bind(this)(...args));
|
|
14123
14013
|
},
|
|
@@ -14132,7 +14022,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14132
14022
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14133
14023
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14134
14024
|
],
|
|
14135
|
-
returns: ["NUMBER"],
|
|
14136
14025
|
compute: function (...args) {
|
|
14137
14026
|
return Math.sqrt(VAR_P.compute.bind(this)(...args));
|
|
14138
14027
|
},
|
|
@@ -14147,7 +14036,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14147
14036
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14148
14037
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14149
14038
|
],
|
|
14150
|
-
returns: ["NUMBER"],
|
|
14151
14039
|
compute: function (...args) {
|
|
14152
14040
|
return Math.sqrt(VAR_S.compute.bind(this)(...args));
|
|
14153
14041
|
},
|
|
@@ -14162,7 +14050,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14162
14050
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14163
14051
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14164
14052
|
],
|
|
14165
|
-
returns: ["NUMBER"],
|
|
14166
14053
|
compute: function (...args) {
|
|
14167
14054
|
return Math.sqrt(VARA.compute.bind(this)(...args));
|
|
14168
14055
|
},
|
|
@@ -14177,7 +14064,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14177
14064
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14178
14065
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14179
14066
|
],
|
|
14180
|
-
returns: ["NUMBER"],
|
|
14181
14067
|
compute: function (...args) {
|
|
14182
14068
|
return Math.sqrt(VARP.compute.bind(this)(...args));
|
|
14183
14069
|
},
|
|
@@ -14192,7 +14078,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14192
14078
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14193
14079
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14194
14080
|
],
|
|
14195
|
-
returns: ["NUMBER"],
|
|
14196
14081
|
compute: function (...args) {
|
|
14197
14082
|
return Math.sqrt(VARPA.compute.bind(this)(...args));
|
|
14198
14083
|
},
|
|
@@ -14207,7 +14092,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14207
14092
|
arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
|
|
14208
14093
|
arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
|
|
14209
14094
|
],
|
|
14210
|
-
returns: ["NUMBER"],
|
|
14211
14095
|
compute: function (dataY, dataX) {
|
|
14212
14096
|
const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
|
|
14213
14097
|
const data = fullLinearRegression([flatDataX], [flatDataY], true, true);
|
|
@@ -14226,7 +14110,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14226
14110
|
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
14111
|
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
14112
|
],
|
|
14229
|
-
returns: ["NUMBER"],
|
|
14230
14113
|
compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
|
|
14231
14114
|
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
14115
|
},
|
|
@@ -14240,7 +14123,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14240
14123
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14241
14124
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14242
14125
|
],
|
|
14243
|
-
returns: ["NUMBER"],
|
|
14244
14126
|
compute: function (...args) {
|
|
14245
14127
|
return variance(args, true, false, this.locale);
|
|
14246
14128
|
},
|
|
@@ -14255,7 +14137,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14255
14137
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14256
14138
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14257
14139
|
],
|
|
14258
|
-
returns: ["NUMBER"],
|
|
14259
14140
|
compute: function (...args) {
|
|
14260
14141
|
return variance(args, false, false, this.locale);
|
|
14261
14142
|
},
|
|
@@ -14270,7 +14151,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14270
14151
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14271
14152
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14272
14153
|
],
|
|
14273
|
-
returns: ["NUMBER"],
|
|
14274
14154
|
compute: function (...args) {
|
|
14275
14155
|
return variance(args, true, false, this.locale);
|
|
14276
14156
|
},
|
|
@@ -14285,7 +14165,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14285
14165
|
arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
|
|
14286
14166
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
|
|
14287
14167
|
],
|
|
14288
|
-
returns: ["NUMBER"],
|
|
14289
14168
|
compute: function (...args) {
|
|
14290
14169
|
return variance(args, true, true, this.locale);
|
|
14291
14170
|
},
|
|
@@ -14300,7 +14179,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14300
14179
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14301
14180
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14302
14181
|
],
|
|
14303
|
-
returns: ["NUMBER"],
|
|
14304
14182
|
compute: function (...args) {
|
|
14305
14183
|
return variance(args, false, false, this.locale);
|
|
14306
14184
|
},
|
|
@@ -14315,7 +14193,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14315
14193
|
arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
|
|
14316
14194
|
arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
|
|
14317
14195
|
],
|
|
14318
|
-
returns: ["NUMBER"],
|
|
14319
14196
|
compute: function (...args) {
|
|
14320
14197
|
return variance(args, false, true, this.locale);
|
|
14321
14198
|
},
|
|
@@ -14481,7 +14358,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14481
14358
|
const DAVERAGE = {
|
|
14482
14359
|
description: _t("Average of a set of values from a table-like range."),
|
|
14483
14360
|
args: databaseArgs,
|
|
14484
|
-
returns: ["NUMBER"],
|
|
14485
14361
|
compute: function (database, field, criteria) {
|
|
14486
14362
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14487
14363
|
return AVERAGE.compute.bind(this)([cells]);
|
|
@@ -14494,7 +14370,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14494
14370
|
const DCOUNT = {
|
|
14495
14371
|
description: _t("Counts values from a table-like range."),
|
|
14496
14372
|
args: databaseArgs,
|
|
14497
|
-
returns: ["NUMBER"],
|
|
14498
14373
|
compute: function (database, field, criteria) {
|
|
14499
14374
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14500
14375
|
return COUNT.compute.bind(this)([cells]);
|
|
@@ -14507,7 +14382,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14507
14382
|
const DCOUNTA = {
|
|
14508
14383
|
description: _t("Counts values and text from a table-like range."),
|
|
14509
14384
|
args: databaseArgs,
|
|
14510
|
-
returns: ["NUMBER"],
|
|
14511
14385
|
compute: function (database, field, criteria) {
|
|
14512
14386
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14513
14387
|
return COUNTA.compute.bind(this)([cells]);
|
|
@@ -14520,7 +14394,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14520
14394
|
const DGET = {
|
|
14521
14395
|
description: _t("Single value from a table-like range."),
|
|
14522
14396
|
args: databaseArgs,
|
|
14523
|
-
returns: ["NUMBER"],
|
|
14524
14397
|
compute: function (database, field, criteria) {
|
|
14525
14398
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14526
14399
|
assert(() => cells.length === 1, _t("More than one match found in DGET evaluation."));
|
|
@@ -14534,7 +14407,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14534
14407
|
const DMAX = {
|
|
14535
14408
|
description: _t("Maximum of values from a table-like range."),
|
|
14536
14409
|
args: databaseArgs,
|
|
14537
|
-
returns: ["NUMBER"],
|
|
14538
14410
|
compute: function (database, field, criteria) {
|
|
14539
14411
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14540
14412
|
return MAX.compute.bind(this)([cells]);
|
|
@@ -14547,7 +14419,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14547
14419
|
const DMIN = {
|
|
14548
14420
|
description: _t("Minimum of values from a table-like range."),
|
|
14549
14421
|
args: databaseArgs,
|
|
14550
|
-
returns: ["NUMBER"],
|
|
14551
14422
|
compute: function (database, field, criteria) {
|
|
14552
14423
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14553
14424
|
return MIN.compute.bind(this)([cells]);
|
|
@@ -14560,7 +14431,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14560
14431
|
const DPRODUCT = {
|
|
14561
14432
|
description: _t("Product of values from a table-like range."),
|
|
14562
14433
|
args: databaseArgs,
|
|
14563
|
-
returns: ["NUMBER"],
|
|
14564
14434
|
compute: function (database, field, criteria) {
|
|
14565
14435
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14566
14436
|
return PRODUCT.compute.bind(this)([cells]);
|
|
@@ -14573,7 +14443,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14573
14443
|
const DSTDEV = {
|
|
14574
14444
|
description: _t("Standard deviation of population sample from table."),
|
|
14575
14445
|
args: databaseArgs,
|
|
14576
|
-
returns: ["NUMBER"],
|
|
14577
14446
|
compute: function (database, field, criteria) {
|
|
14578
14447
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14579
14448
|
return STDEV.compute.bind(this)([cells]);
|
|
@@ -14586,7 +14455,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14586
14455
|
const DSTDEVP = {
|
|
14587
14456
|
description: _t("Standard deviation of entire population from table."),
|
|
14588
14457
|
args: databaseArgs,
|
|
14589
|
-
returns: ["NUMBER"],
|
|
14590
14458
|
compute: function (database, field, criteria) {
|
|
14591
14459
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14592
14460
|
return STDEVP.compute.bind(this)([cells]);
|
|
@@ -14599,7 +14467,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14599
14467
|
const DSUM = {
|
|
14600
14468
|
description: _t("Sum of values from a table-like range."),
|
|
14601
14469
|
args: databaseArgs,
|
|
14602
|
-
returns: ["NUMBER"],
|
|
14603
14470
|
compute: function (database, field, criteria) {
|
|
14604
14471
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14605
14472
|
return SUM.compute.bind(this)([cells]);
|
|
@@ -14612,7 +14479,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14612
14479
|
const DVAR = {
|
|
14613
14480
|
description: _t("Variance of population sample from table-like range."),
|
|
14614
14481
|
args: databaseArgs,
|
|
14615
|
-
returns: ["NUMBER"],
|
|
14616
14482
|
compute: function (database, field, criteria) {
|
|
14617
14483
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14618
14484
|
return VAR.compute.bind(this)([cells]);
|
|
@@ -14625,7 +14491,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14625
14491
|
const DVARP = {
|
|
14626
14492
|
description: _t("Variance of a population from a table-like range."),
|
|
14627
14493
|
args: databaseArgs,
|
|
14628
|
-
returns: ["NUMBER"],
|
|
14629
14494
|
compute: function (database, field, criteria) {
|
|
14630
14495
|
const cells = getMatchingCells(database, field, criteria, this.locale);
|
|
14631
14496
|
return VARP.compute.bind(this)([cells]);
|
|
@@ -14670,7 +14535,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14670
14535
|
arg("month (number)", _t("The month component of the date.")),
|
|
14671
14536
|
arg("day (number)", _t("The day component of the date.")),
|
|
14672
14537
|
],
|
|
14673
|
-
returns: ["DATE"],
|
|
14674
14538
|
compute: function (year, month, day) {
|
|
14675
14539
|
let _year = Math.trunc(toNumber(year, this.locale));
|
|
14676
14540
|
const _month = Math.trunc(toNumber(month, this.locale));
|
|
@@ -14701,7 +14565,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14701
14565
|
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
14566
|
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
14567
|
],
|
|
14704
|
-
returns: ["NUMBER"],
|
|
14705
14568
|
compute: function (startDate, endDate, unit) {
|
|
14706
14569
|
const _unit = toString(unit).toUpperCase();
|
|
14707
14570
|
assert(() => Object.values(TIME_UNIT).includes(_unit), expectStringSetError(Object.values(TIME_UNIT), toString(unit)));
|
|
@@ -14754,7 +14617,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14754
14617
|
const DATEVALUE = {
|
|
14755
14618
|
description: _t("Converts a date string to a date value."),
|
|
14756
14619
|
args: [arg("date_string (string)", _t("The string representing the date."))],
|
|
14757
|
-
returns: ["NUMBER"],
|
|
14758
14620
|
compute: function (dateString) {
|
|
14759
14621
|
const _dateString = toString(dateString);
|
|
14760
14622
|
const internalDate = parseDateTime(_dateString, this.locale);
|
|
@@ -14769,7 +14631,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14769
14631
|
const DAY = {
|
|
14770
14632
|
description: _t("Day of the month that a specific date falls on."),
|
|
14771
14633
|
args: [arg("date (string)", _t("The date from which to extract the day."))],
|
|
14772
|
-
returns: ["NUMBER"],
|
|
14773
14634
|
compute: function (date) {
|
|
14774
14635
|
return toJsDate(date, this.locale).getDate();
|
|
14775
14636
|
},
|
|
@@ -14784,7 +14645,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14784
14645
|
arg("end_date (date)", _t("The end of the date range.")),
|
|
14785
14646
|
arg("start_date (date)", _t("The start of the date range.")),
|
|
14786
14647
|
],
|
|
14787
|
-
returns: ["NUMBER"],
|
|
14788
14648
|
compute: function (endDate, startDate) {
|
|
14789
14649
|
const _endDate = toJsDate(endDate, this.locale);
|
|
14790
14650
|
const _startDate = toJsDate(startDate, this.locale);
|
|
@@ -14804,7 +14664,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14804
14664
|
arg("end_date (date)", _t("The end date to consider in the calculation.")),
|
|
14805
14665
|
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
14666
|
],
|
|
14807
|
-
returns: ["NUMBER"],
|
|
14808
14667
|
compute: function (startDate, endDate, method = { value: DEFAULT_DAY_COUNT_METHOD }) {
|
|
14809
14668
|
const _startDate = Math.trunc(toNumber(startDate, this.locale));
|
|
14810
14669
|
const _endDate = Math.trunc(toNumber(endDate, this.locale));
|
|
@@ -14823,7 +14682,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14823
14682
|
arg("start_date (date)", _t("The date from which to calculate the result.")),
|
|
14824
14683
|
arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to calculate.")),
|
|
14825
14684
|
],
|
|
14826
|
-
returns: ["DATE"],
|
|
14827
14685
|
compute: function (startDate, months) {
|
|
14828
14686
|
const _startDate = toJsDate(startDate, this.locale);
|
|
14829
14687
|
const _months = Math.trunc(toNumber(months, this.locale));
|
|
@@ -14844,7 +14702,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14844
14702
|
arg("start_date (date)", _t("The date from which to calculate the result.")),
|
|
14845
14703
|
arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to consider.")),
|
|
14846
14704
|
],
|
|
14847
|
-
returns: ["DATE"],
|
|
14848
14705
|
compute: function (startDate, months) {
|
|
14849
14706
|
const _startDate = toJsDate(startDate, this.locale);
|
|
14850
14707
|
const _months = Math.trunc(toNumber(months, this.locale));
|
|
@@ -14864,7 +14721,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14864
14721
|
const HOUR = {
|
|
14865
14722
|
description: _t("Hour component of a specific time."),
|
|
14866
14723
|
args: [arg("time (date)", _t("The time from which to calculate the hour component."))],
|
|
14867
|
-
returns: ["NUMBER"],
|
|
14868
14724
|
compute: function (date) {
|
|
14869
14725
|
return toJsDate(date, this.locale).getHours();
|
|
14870
14726
|
},
|
|
@@ -14878,7 +14734,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14878
14734
|
args: [
|
|
14879
14735
|
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
14736
|
],
|
|
14881
|
-
returns: ["NUMBER"],
|
|
14882
14737
|
compute: function (date) {
|
|
14883
14738
|
const _date = toJsDate(date, this.locale);
|
|
14884
14739
|
const y = _date.getFullYear();
|
|
@@ -14950,7 +14805,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14950
14805
|
const MINUTE = {
|
|
14951
14806
|
description: _t("Minute component of a specific time."),
|
|
14952
14807
|
args: [arg("time (date)", _t("The time from which to calculate the minute component."))],
|
|
14953
|
-
returns: ["NUMBER"],
|
|
14954
14808
|
compute: function (date) {
|
|
14955
14809
|
return toJsDate(date, this.locale).getMinutes();
|
|
14956
14810
|
},
|
|
@@ -14962,7 +14816,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14962
14816
|
const MONTH = {
|
|
14963
14817
|
description: _t("Month of the year a specific date falls in"),
|
|
14964
14818
|
args: [arg("date (date)", _t("The date from which to extract the month."))],
|
|
14965
|
-
returns: ["NUMBER"],
|
|
14966
14819
|
compute: function (date) {
|
|
14967
14820
|
return toJsDate(date, this.locale).getMonth() + 1;
|
|
14968
14821
|
},
|
|
@@ -14978,7 +14831,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
14978
14831
|
arg("end_date (date)", _t("The end date of the period from which to calculate the number of net working days.")),
|
|
14979
14832
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the date serial numbers to consider holidays.")),
|
|
14980
14833
|
],
|
|
14981
|
-
returns: ["NUMBER"],
|
|
14982
14834
|
compute: function (startDate, endDate, holidays) {
|
|
14983
14835
|
return NETWORKDAYS_INTL.compute.bind(this)(startDate, endDate, { value: 1 }, holidays);
|
|
14984
14836
|
},
|
|
@@ -15059,7 +14911,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15059
14911
|
arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
|
|
15060
14912
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider as holidays.")),
|
|
15061
14913
|
],
|
|
15062
|
-
returns: ["NUMBER"],
|
|
15063
14914
|
compute: function (startDate, endDate, weekend = { value: DEFAULT_WEEKEND }, holidays) {
|
|
15064
14915
|
const _startDate = toJsDate(startDate, this.locale);
|
|
15065
14916
|
const _endDate = toJsDate(endDate, this.locale);
|
|
@@ -15094,7 +14945,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15094
14945
|
const NOW = {
|
|
15095
14946
|
description: _t("Current date and time as a date value."),
|
|
15096
14947
|
args: [],
|
|
15097
|
-
returns: ["DATE"],
|
|
15098
14948
|
compute: function () {
|
|
15099
14949
|
const today = DateTime.now();
|
|
15100
14950
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
@@ -15112,7 +14962,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15112
14962
|
const SECOND = {
|
|
15113
14963
|
description: _t("Minute component of a specific time."),
|
|
15114
14964
|
args: [arg("time (date)", _t("The time from which to calculate the second component."))],
|
|
15115
|
-
returns: ["NUMBER"],
|
|
15116
14965
|
compute: function (date) {
|
|
15117
14966
|
return toJsDate(date, this.locale).getSeconds();
|
|
15118
14967
|
},
|
|
@@ -15128,7 +14977,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15128
14977
|
arg("minute (number)", _t("The minute component of the time.")),
|
|
15129
14978
|
arg("second (number)", _t("The second component of the time.")),
|
|
15130
14979
|
],
|
|
15131
|
-
returns: ["DATE"],
|
|
15132
14980
|
compute: function (hour, minute, second) {
|
|
15133
14981
|
let _hour = Math.trunc(toNumber(hour, this.locale));
|
|
15134
14982
|
let _minute = Math.trunc(toNumber(minute, this.locale));
|
|
@@ -15152,7 +15000,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15152
15000
|
const TIMEVALUE = {
|
|
15153
15001
|
description: _t("Converts a time string into its serial number representation."),
|
|
15154
15002
|
args: [arg("time_string (string)", _t("The string that holds the time representation."))],
|
|
15155
|
-
returns: ["NUMBER"],
|
|
15156
15003
|
compute: function (timeString) {
|
|
15157
15004
|
const _timeString = toString(timeString);
|
|
15158
15005
|
const internalDate = parseDateTime(_timeString, this.locale);
|
|
@@ -15168,7 +15015,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15168
15015
|
const TODAY = {
|
|
15169
15016
|
description: _t("Current date as a date value."),
|
|
15170
15017
|
args: [],
|
|
15171
|
-
returns: ["DATE"],
|
|
15172
15018
|
compute: function () {
|
|
15173
15019
|
const today = DateTime.now();
|
|
15174
15020
|
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
@@ -15188,7 +15034,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15188
15034
|
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
15035
|
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
15036
|
],
|
|
15191
|
-
returns: ["NUMBER"],
|
|
15192
15037
|
compute: function (date, type = { value: DEFAULT_TYPE }) {
|
|
15193
15038
|
const _date = toJsDate(date, this.locale);
|
|
15194
15039
|
const _type = Math.round(toNumber(type, this.locale));
|
|
@@ -15211,7 +15056,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15211
15056
|
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
15057
|
arg(`type (number, default=${DEFAULT_TYPE})`, _t("A number representing the day that a week starts on. Sunday = 1.")),
|
|
15213
15058
|
],
|
|
15214
|
-
returns: ["NUMBER"],
|
|
15215
15059
|
compute: function (date, type = { value: DEFAULT_TYPE }) {
|
|
15216
15060
|
const _date = toJsDate(date, this.locale);
|
|
15217
15061
|
const _type = Math.round(toNumber(type, this.locale));
|
|
@@ -15252,7 +15096,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15252
15096
|
arg("num_days (number)", _t("The number of working days to advance from start_date. If negative, counts backwards.")),
|
|
15253
15097
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
|
|
15254
15098
|
],
|
|
15255
|
-
returns: ["NUMBER"],
|
|
15256
15099
|
compute: function (startDate, numDays, holidays = { value: null }) {
|
|
15257
15100
|
return WORKDAY_INTL.compute.bind(this)(startDate, numDays, { value: 1 }, holidays);
|
|
15258
15101
|
},
|
|
@@ -15269,7 +15112,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15269
15112
|
arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
|
|
15270
15113
|
arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
|
|
15271
15114
|
],
|
|
15272
|
-
returns: ["DATE"],
|
|
15273
15115
|
compute: function (startDate, numDays, weekend = { value: DEFAULT_WEEKEND }, holidays) {
|
|
15274
15116
|
let _startDate = toJsDate(startDate, this.locale);
|
|
15275
15117
|
let _numDays = Math.trunc(toNumber(numDays, this.locale));
|
|
@@ -15309,7 +15151,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15309
15151
|
const YEAR = {
|
|
15310
15152
|
description: _t("Year specified by a given date."),
|
|
15311
15153
|
args: [arg("date (date)", _t("The date from which to extract the year."))],
|
|
15312
|
-
returns: ["NUMBER"],
|
|
15313
15154
|
compute: function (date) {
|
|
15314
15155
|
return toJsDate(date, this.locale).getFullYear();
|
|
15315
15156
|
},
|
|
@@ -15326,7 +15167,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15326
15167
|
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
15168
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION$1})`, _t("An indicator of what day count method to use.")),
|
|
15328
15169
|
],
|
|
15329
|
-
returns: ["NUMBER"],
|
|
15330
15170
|
compute: function (startDate, endDate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION$1 }) {
|
|
15331
15171
|
let _startDate = Math.trunc(toNumber(startDate, this.locale));
|
|
15332
15172
|
let _endDate = Math.trunc(toNumber(endDate, this.locale));
|
|
@@ -15343,7 +15183,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15343
15183
|
const MONTH_START = {
|
|
15344
15184
|
description: _t("First day of the month preceding a date."),
|
|
15345
15185
|
args: [arg("date (date)", _t("The date from which to calculate the result."))],
|
|
15346
|
-
returns: ["DATE"],
|
|
15347
15186
|
compute: function (date) {
|
|
15348
15187
|
const _startDate = toJsDate(date, this.locale);
|
|
15349
15188
|
const yStart = _startDate.getFullYear();
|
|
@@ -15361,7 +15200,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15361
15200
|
const MONTH_END = {
|
|
15362
15201
|
description: _t("Last day of the month following a date."),
|
|
15363
15202
|
args: [arg("date (date)", _t("The date from which to calculate the result."))],
|
|
15364
|
-
returns: ["DATE"],
|
|
15365
15203
|
compute: function (date) {
|
|
15366
15204
|
return EOMONTH.compute.bind(this)(date, { value: 0 });
|
|
15367
15205
|
},
|
|
@@ -15372,7 +15210,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15372
15210
|
const QUARTER = {
|
|
15373
15211
|
description: _t("Quarter of the year a specific date falls in"),
|
|
15374
15212
|
args: [arg("date (date)", _t("The date from which to extract the quarter."))],
|
|
15375
|
-
returns: ["NUMBER"],
|
|
15376
15213
|
compute: function (date) {
|
|
15377
15214
|
return Math.ceil((toJsDate(date, this.locale).getMonth() + 1) / 3);
|
|
15378
15215
|
},
|
|
@@ -15383,7 +15220,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15383
15220
|
const QUARTER_START = {
|
|
15384
15221
|
description: _t("First day of the quarter of the year a specific date falls in."),
|
|
15385
15222
|
args: [arg("date (date)", _t("The date from which to calculate the start of quarter."))],
|
|
15386
|
-
returns: ["DATE"],
|
|
15387
15223
|
compute: function (date) {
|
|
15388
15224
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15389
15225
|
const year = YEAR.compute.bind(this)(date);
|
|
@@ -15400,7 +15236,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15400
15236
|
const QUARTER_END = {
|
|
15401
15237
|
description: _t("Last day of the quarter of the year a specific date falls in."),
|
|
15402
15238
|
args: [arg("date (date)", _t("The date from which to calculate the end of quarter."))],
|
|
15403
|
-
returns: ["DATE"],
|
|
15404
15239
|
compute: function (date) {
|
|
15405
15240
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15406
15241
|
const year = YEAR.compute.bind(this)(date);
|
|
@@ -15417,7 +15252,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15417
15252
|
const YEAR_START = {
|
|
15418
15253
|
description: _t("First day of the year a specific date falls in."),
|
|
15419
15254
|
args: [arg("date (date)", _t("The date from which to calculate the start of the year."))],
|
|
15420
|
-
returns: ["DATE"],
|
|
15421
15255
|
compute: function (date) {
|
|
15422
15256
|
const year = YEAR.compute.bind(this)(date);
|
|
15423
15257
|
const jsDate = new DateTime(year, 0, 1);
|
|
@@ -15433,7 +15267,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15433
15267
|
const YEAR_END = {
|
|
15434
15268
|
description: _t("Last day of the year a specific date falls in."),
|
|
15435
15269
|
args: [arg("date (date)", _t("The date from which to calculate the end of the year."))],
|
|
15436
|
-
returns: ["DATE"],
|
|
15437
15270
|
compute: function (date) {
|
|
15438
15271
|
const year = YEAR.compute.bind(this)(date);
|
|
15439
15272
|
const jsDate = new DateTime(year + 1, 0, 0);
|
|
@@ -15490,7 +15323,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15490
15323
|
arg("number1 (number)", _t("The first number to compare.")),
|
|
15491
15324
|
arg(`number2 (number, default=${DEFAULT_DELTA_ARG})`, _t("The second number to compare.")),
|
|
15492
15325
|
],
|
|
15493
|
-
returns: ["NUMBER"],
|
|
15494
15326
|
compute: function (number1, number2 = { value: DEFAULT_DELTA_ARG }) {
|
|
15495
15327
|
const _number1 = toNumber(number1, this.locale);
|
|
15496
15328
|
const _number2 = toNumber(number2, this.locale);
|
|
@@ -15681,7 +15513,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15681
15513
|
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
15514
|
arg("condition2 (boolean, range<boolean>, repeating)", _t("Additional column or row containing true or false values.")),
|
|
15683
15515
|
],
|
|
15684
|
-
returns: ["RANGE<ANY>"],
|
|
15685
15516
|
compute: function (range, ...conditions) {
|
|
15686
15517
|
let _array = toMatrix(range);
|
|
15687
15518
|
const _conditionsMatrices = conditions.map((cond) => matrixMap(toMatrix(cond), (data) => data.value));
|
|
@@ -15715,7 +15546,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15715
15546
|
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
15547
|
arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
|
|
15717
15548
|
],
|
|
15718
|
-
returns: ["RANGE"],
|
|
15719
15549
|
compute: function (range, ...sortingCriteria) {
|
|
15720
15550
|
const _range = transposeMatrix(range);
|
|
15721
15551
|
return transposeMatrix(sortMatrix(_range, this.locale, ...sortingCriteria));
|
|
@@ -15734,7 +15564,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15734
15564
|
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
15565
|
arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
|
|
15736
15566
|
],
|
|
15737
|
-
returns: ["RANGE"],
|
|
15738
15567
|
compute: function (range, n, displayTiesMode, ...sortingCriteria) {
|
|
15739
15568
|
const _n = toNumber(n?.value ?? 1, this.locale);
|
|
15740
15569
|
assert(() => _n >= 0, _t("Wrong value of 'n'. Expected a positive number. Got %s.", _n));
|
|
@@ -15802,7 +15631,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
15802
15631
|
arg("by_column (boolean, default=FALSE)", _t("Whether to filter the data by columns or by rows.")),
|
|
15803
15632
|
arg("exactly_once (boolean, default=FALSE)", _t("Whether to return only entries with no duplicates.")),
|
|
15804
15633
|
],
|
|
15805
|
-
returns: ["RANGE<NUMBER>"],
|
|
15806
15634
|
compute: function (range = { value: "" }, byColumn, exactlyOnce) {
|
|
15807
15635
|
if (!isMatrix(range)) {
|
|
15808
15636
|
return [[range]];
|
|
@@ -16027,7 +15855,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16027
15855
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
16028
15856
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16029
15857
|
],
|
|
16030
|
-
returns: ["NUMBER"],
|
|
16031
15858
|
compute: function (issue, maturity, rate, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16032
15859
|
const start = Math.trunc(toNumber(issue, this.locale));
|
|
16033
15860
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16058,7 +15885,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16058
15885
|
arg("rate (number)", _t("The deprecation rate.")),
|
|
16059
15886
|
arg("day_count_convention (number, optional)", _t("An indicator of what day count method to use.")),
|
|
16060
15887
|
],
|
|
16061
|
-
returns: ["NUMBER"],
|
|
16062
15888
|
compute: function (cost, purchaseDate, firstPeriodEnd, salvage, period, rate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16063
15889
|
dayCountConvention = dayCountConvention || 0;
|
|
16064
15890
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -16107,7 +15933,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16107
15933
|
const COUPDAYS = {
|
|
16108
15934
|
description: _t("Days in coupon period containing settlement date."),
|
|
16109
15935
|
args: COUPON_FUNCTION_ARGS,
|
|
16110
|
-
returns: ["NUMBER"],
|
|
16111
15936
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16112
15937
|
dayCountConvention = dayCountConvention || 0;
|
|
16113
15938
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16134,7 +15959,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16134
15959
|
const COUPDAYBS = {
|
|
16135
15960
|
description: _t("Days from settlement until next coupon."),
|
|
16136
15961
|
args: COUPON_FUNCTION_ARGS,
|
|
16137
|
-
returns: ["NUMBER"],
|
|
16138
15962
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16139
15963
|
dayCountConvention = dayCountConvention || 0;
|
|
16140
15964
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16191,7 +16015,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16191
16015
|
const COUPDAYSNC = {
|
|
16192
16016
|
description: _t("Days from settlement until next coupon."),
|
|
16193
16017
|
args: COUPON_FUNCTION_ARGS,
|
|
16194
|
-
returns: ["NUMBER"],
|
|
16195
16018
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16196
16019
|
dayCountConvention = dayCountConvention || 0;
|
|
16197
16020
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16221,7 +16044,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16221
16044
|
const COUPNCD = {
|
|
16222
16045
|
description: _t("Next coupon date after the settlement date."),
|
|
16223
16046
|
args: COUPON_FUNCTION_ARGS,
|
|
16224
|
-
returns: ["NUMBER"],
|
|
16225
16047
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16226
16048
|
dayCountConvention = dayCountConvention || 0;
|
|
16227
16049
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16247,7 +16069,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16247
16069
|
const COUPNUM = {
|
|
16248
16070
|
description: _t("Number of coupons between settlement and maturity."),
|
|
16249
16071
|
args: COUPON_FUNCTION_ARGS,
|
|
16250
|
-
returns: ["NUMBER"],
|
|
16251
16072
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16252
16073
|
dayCountConvention = dayCountConvention || 0;
|
|
16253
16074
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16274,7 +16095,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16274
16095
|
const COUPPCD = {
|
|
16275
16096
|
description: _t("Last coupon date prior to or on the settlement date."),
|
|
16276
16097
|
args: COUPON_FUNCTION_ARGS,
|
|
16277
|
-
returns: ["NUMBER"],
|
|
16278
16098
|
compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16279
16099
|
dayCountConvention = dayCountConvention || 0;
|
|
16280
16100
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16307,7 +16127,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16307
16127
|
arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
|
|
16308
16128
|
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
16129
|
],
|
|
16310
|
-
returns: ["NUMBER"],
|
|
16311
16130
|
compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16312
16131
|
const first = toNumber(firstPeriod, this.locale);
|
|
16313
16132
|
const last = toNumber(lastPeriod, this.locale);
|
|
@@ -16339,7 +16158,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16339
16158
|
arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
|
|
16340
16159
|
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
16160
|
],
|
|
16342
|
-
returns: ["NUMBER"],
|
|
16343
16161
|
compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16344
16162
|
const first = toNumber(firstPeriod, this.locale);
|
|
16345
16163
|
const last = toNumber(lastPeriod, this.locale);
|
|
@@ -16370,7 +16188,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16370
16188
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
16371
16189
|
arg("month (number, optional)", _t("The number of months in the first year of depreciation.")),
|
|
16372
16190
|
],
|
|
16373
|
-
returns: ["NUMBER"],
|
|
16374
16191
|
// to do: replace by dollar format
|
|
16375
16192
|
compute: function (cost, salvage, life, period, ...args) {
|
|
16376
16193
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -16439,7 +16256,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16439
16256
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
16440
16257
|
arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The factor by which depreciation decreases.")),
|
|
16441
16258
|
],
|
|
16442
|
-
returns: ["NUMBER"],
|
|
16443
16259
|
compute: function (cost, salvage, life, period, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }) {
|
|
16444
16260
|
const _cost = toNumber(cost, this.locale);
|
|
16445
16261
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -16465,7 +16281,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16465
16281
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
16466
16282
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16467
16283
|
],
|
|
16468
|
-
returns: ["NUMBER"],
|
|
16469
16284
|
compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16470
16285
|
dayCountConvention = dayCountConvention || 0;
|
|
16471
16286
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -16501,7 +16316,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16501
16316
|
arg("fractional_price (number)", _t("The price quotation given using fractional decimal conventions.")),
|
|
16502
16317
|
arg("unit (number)", _t("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
|
|
16503
16318
|
],
|
|
16504
|
-
returns: ["NUMBER"],
|
|
16505
16319
|
compute: function (fractionalPrice, unit) {
|
|
16506
16320
|
const price = toNumber(fractionalPrice, this.locale);
|
|
16507
16321
|
const _unit = Math.trunc(toNumber(unit, this.locale));
|
|
@@ -16522,7 +16336,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16522
16336
|
arg("decimal_price (number)", _t("The price quotation given as a decimal value.")),
|
|
16523
16337
|
arg("unit (number)", _t("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
|
|
16524
16338
|
],
|
|
16525
|
-
returns: ["NUMBER"],
|
|
16526
16339
|
compute: function (decimalPrice, unit) {
|
|
16527
16340
|
const price = toNumber(decimalPrice, this.locale);
|
|
16528
16341
|
const _unit = Math.trunc(toNumber(unit, this.locale));
|
|
@@ -16547,7 +16360,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16547
16360
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
16548
16361
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16549
16362
|
],
|
|
16550
|
-
returns: ["NUMBER"],
|
|
16551
16363
|
compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16552
16364
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
16553
16365
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16588,7 +16400,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16588
16400
|
arg("nominal_rate (number)", _t("The nominal interest rate per year.")),
|
|
16589
16401
|
arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
|
|
16590
16402
|
],
|
|
16591
|
-
returns: ["NUMBER"],
|
|
16592
16403
|
compute: function (nominal_rate, periods_per_year) {
|
|
16593
16404
|
const nominal = toNumber(nominal_rate, this.locale);
|
|
16594
16405
|
const periods = Math.trunc(toNumber(periods_per_year, this.locale));
|
|
@@ -16618,7 +16429,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16618
16429
|
arg(`present_value (number, default=${DEFAULT_PRESENT_VALUE})`, _t("The current value of the annuity.")),
|
|
16619
16430
|
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
16431
|
],
|
|
16621
|
-
returns: ["NUMBER"],
|
|
16622
16432
|
// to do: replace by dollar format
|
|
16623
16433
|
compute: function (rate, numberOfPeriods, paymentAmount, presentValue = { value: DEFAULT_PRESENT_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16624
16434
|
presentValue = presentValue || 0;
|
|
@@ -16644,7 +16454,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16644
16454
|
arg("principal (number)", _t("The amount of initial capital or value to compound against.")),
|
|
16645
16455
|
arg("rate_schedule (number, range<number>)", _t("A series of interest rates to compound against the principal.")),
|
|
16646
16456
|
],
|
|
16647
|
-
returns: ["NUMBER"],
|
|
16648
16457
|
compute: function (principalAmount, rateSchedule) {
|
|
16649
16458
|
const principal = toNumber(principalAmount, this.locale);
|
|
16650
16459
|
return reduceAny([rateSchedule], (acc, rate) => acc * (1 + toNumber(rate, this.locale)), principal);
|
|
@@ -16663,7 +16472,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16663
16472
|
arg("redemption (number)", _t("The amount to be received at maturity.")),
|
|
16664
16473
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16665
16474
|
],
|
|
16666
|
-
returns: ["NUMBER"],
|
|
16667
16475
|
compute: function (settlement, maturity, investment, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16668
16476
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
16669
16477
|
const _maturity = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -16702,7 +16510,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16702
16510
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
16703
16511
|
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
16512
|
],
|
|
16705
|
-
returns: ["NUMBER"],
|
|
16706
16513
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16707
16514
|
const r = toNumber(rate, this.locale);
|
|
16708
16515
|
const period = toNumber(currentPeriod, this.locale);
|
|
@@ -16727,7 +16534,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16727
16534
|
arg("cashflow_amounts (number, range<number>)", _t("An array or range containing the income or payments associated with the investment.")),
|
|
16728
16535
|
arg(`rate_guess (number, default=${DEFAULT_RATE_GUESS})`, _t("An estimate for what the internal rate of return will be.")),
|
|
16729
16536
|
],
|
|
16730
|
-
returns: ["NUMBER"],
|
|
16731
16537
|
compute: function (cashFlowAmounts, rateGuess = { value: DEFAULT_RATE_GUESS }) {
|
|
16732
16538
|
const _rateGuess = toNumber(rateGuess, this.locale);
|
|
16733
16539
|
assertRateGuessStrictlyGreaterThanMinusOne(_rateGuess);
|
|
@@ -16789,7 +16595,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16789
16595
|
arg("number_of_periods (number)", _t("The number of payments to be made.")),
|
|
16790
16596
|
arg("present_value (number)", _t("The current value of the annuity.")),
|
|
16791
16597
|
],
|
|
16792
|
-
returns: ["NUMBER"],
|
|
16793
16598
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue) {
|
|
16794
16599
|
const interestRate = toNumber(rate, this.locale);
|
|
16795
16600
|
const period = toNumber(currentPeriod, this.locale);
|
|
@@ -16814,7 +16619,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16814
16619
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
16815
16620
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
16816
16621
|
],
|
|
16817
|
-
returns: ["NUMBER"],
|
|
16818
16622
|
compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
16819
16623
|
const duration = DURATION.compute.bind(this)(settlement, maturity, rate, securityYield, frequency, dayCountConvention);
|
|
16820
16624
|
const y = toNumber(securityYield, this.locale);
|
|
@@ -16833,7 +16637,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16833
16637
|
arg("financing_rate (number)", _t("The interest rate paid on funds invested.")),
|
|
16834
16638
|
arg("reinvestment_return_rate (number)", _t("The return (as a percentage) earned on reinvestment of income received from the investment.")),
|
|
16835
16639
|
],
|
|
16836
|
-
returns: ["NUMBER"],
|
|
16837
16640
|
compute: function (cashflowAmount, financingRate, reinvestmentRate) {
|
|
16838
16641
|
const fRate = toNumber(financingRate, this.locale);
|
|
16839
16642
|
const rRate = toNumber(reinvestmentRate, this.locale);
|
|
@@ -16885,7 +16688,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16885
16688
|
arg("effective_rate (number)", _t("The effective interest rate per year.")),
|
|
16886
16689
|
arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
|
|
16887
16690
|
],
|
|
16888
|
-
returns: ["NUMBER"],
|
|
16889
16691
|
compute: function (effective_rate, periods_per_year) {
|
|
16890
16692
|
const effective = toNumber(effective_rate, this.locale);
|
|
16891
16693
|
const periods = Math.trunc(toNumber(periods_per_year, this.locale));
|
|
@@ -16908,7 +16710,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16908
16710
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
16909
16711
|
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
16712
|
],
|
|
16911
|
-
returns: ["NUMBER"],
|
|
16912
16713
|
compute: function (rate, paymentAmount, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
16913
16714
|
futureValue = futureValue || 0;
|
|
16914
16715
|
endOrBeginning = endOrBeginning || 0;
|
|
@@ -16956,7 +16757,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16956
16757
|
arg("cashflow1 (number, range<number>)", _t("The first future cash flow.")),
|
|
16957
16758
|
arg("cashflow2 (number, range<number>, repeating)", _t("Additional future cash flows.")),
|
|
16958
16759
|
],
|
|
16959
|
-
returns: ["NUMBER"],
|
|
16960
16760
|
// to do: replace by dollar format
|
|
16961
16761
|
compute: function (discount, ...values) {
|
|
16962
16762
|
const _discount = toNumber(discount, this.locale);
|
|
@@ -16978,7 +16778,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
16978
16778
|
arg("present_value (number)", _t("The investment's current value.")),
|
|
16979
16779
|
arg("future_value (number)", _t("The investment's desired future value.")),
|
|
16980
16780
|
],
|
|
16981
|
-
returns: ["NUMBER"],
|
|
16982
16781
|
compute: function (rate, presentValue, futureValue) {
|
|
16983
16782
|
const _rate = toNumber(rate, this.locale);
|
|
16984
16783
|
const _presentValue = toNumber(presentValue, this.locale);
|
|
@@ -17018,7 +16817,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17018
16817
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17019
16818
|
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
16819
|
],
|
|
17021
|
-
returns: ["NUMBER"],
|
|
17022
16820
|
compute: function (rate, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17023
16821
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17024
16822
|
const r = toNumber(rate, this.locale);
|
|
@@ -17054,7 +16852,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17054
16852
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17055
16853
|
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
16854
|
],
|
|
17057
|
-
returns: ["NUMBER"],
|
|
17058
16855
|
compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17059
16856
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17060
16857
|
const r = toNumber(rate, this.locale);
|
|
@@ -17081,7 +16878,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17081
16878
|
arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
|
|
17082
16879
|
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
16880
|
],
|
|
17084
|
-
returns: ["NUMBER"],
|
|
17085
16881
|
// to do: replace by dollar format
|
|
17086
16882
|
compute: function (rate, numberOfPeriods, paymentAmount, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
|
|
17087
16883
|
futureValue = futureValue || 0;
|
|
@@ -17115,7 +16911,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17115
16911
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
17116
16912
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17117
16913
|
],
|
|
17118
|
-
returns: ["NUMBER"],
|
|
17119
16914
|
compute: function (settlement, maturity, rate, securityYield, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17120
16915
|
dayCountConvention = dayCountConvention || 0;
|
|
17121
16916
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17163,7 +16958,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17163
16958
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
17164
16959
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17165
16960
|
],
|
|
17166
|
-
returns: ["NUMBER"],
|
|
17167
16961
|
compute: function (settlement, maturity, discount, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17168
16962
|
dayCountConvention = dayCountConvention || 0;
|
|
17169
16963
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17201,7 +16995,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17201
16995
|
arg("yield (number)", _t("The expected annual yield of the security.")),
|
|
17202
16996
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17203
16997
|
],
|
|
17204
|
-
returns: ["NUMBER"],
|
|
17205
16998
|
compute: function (settlement, maturity, issue, rate, securityYield, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17206
16999
|
dayCountConvention = dayCountConvention || 0;
|
|
17207
17000
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17265,7 +17058,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17265
17058
|
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
17059
|
arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the interest rate will be.")),
|
|
17267
17060
|
],
|
|
17268
|
-
returns: ["NUMBER"],
|
|
17269
17061
|
compute: function (numberOfPeriods, paymentPerPeriod, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }, rateGuess = { value: RATE_GUESS_DEFAULT }) {
|
|
17270
17062
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17271
17063
|
const payment = toNumber(paymentPerPeriod, this.locale);
|
|
@@ -17311,7 +17103,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17311
17103
|
arg("discount (number)", _t("The discount rate of the security invested in.")),
|
|
17312
17104
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17313
17105
|
],
|
|
17314
|
-
returns: ["NUMBER"],
|
|
17315
17106
|
compute: function (settlement, maturity, investment, discount, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17316
17107
|
dayCountConvention = dayCountConvention || 0;
|
|
17317
17108
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17349,7 +17140,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17349
17140
|
arg("present_value (number)", _t("The present value of the investment.")),
|
|
17350
17141
|
arg("future_value (number)", _t("The future value of the investment.")),
|
|
17351
17142
|
],
|
|
17352
|
-
returns: ["NUMBER"],
|
|
17353
17143
|
compute: function (numberOfPeriods, presentValue, futureValue) {
|
|
17354
17144
|
const n = toNumber(numberOfPeriods, this.locale);
|
|
17355
17145
|
const pv = toNumber(presentValue, this.locale);
|
|
@@ -17374,7 +17164,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17374
17164
|
arg("salvage (number)", _t("The value of the asset at the end of depreciation.")),
|
|
17375
17165
|
arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
|
|
17376
17166
|
],
|
|
17377
|
-
returns: ["NUMBER"],
|
|
17378
17167
|
compute: function (cost, salvage, life) {
|
|
17379
17168
|
const _cost = toNumber(cost, this.locale);
|
|
17380
17169
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -17399,7 +17188,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17399
17188
|
arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
|
|
17400
17189
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
17401
17190
|
],
|
|
17402
|
-
returns: ["NUMBER"],
|
|
17403
17191
|
compute: function (cost, salvage, life, period) {
|
|
17404
17192
|
const _cost = toNumber(cost, this.locale);
|
|
17405
17193
|
const _salvage = toNumber(salvage, this.locale);
|
|
@@ -17448,7 +17236,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17448
17236
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17449
17237
|
arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
|
|
17450
17238
|
],
|
|
17451
|
-
returns: ["NUMBER"],
|
|
17452
17239
|
compute: function (settlement, maturity, discount) {
|
|
17453
17240
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17454
17241
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17471,7 +17258,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17471
17258
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17472
17259
|
arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
|
|
17473
17260
|
],
|
|
17474
|
-
returns: ["NUMBER"],
|
|
17475
17261
|
compute: function (settlement, maturity, discount) {
|
|
17476
17262
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17477
17263
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17529,7 +17315,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17529
17315
|
arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
|
|
17530
17316
|
arg("price (number)", _t("The price at which the security is bought per 100 face value.")),
|
|
17531
17317
|
],
|
|
17532
|
-
returns: ["NUMBER"],
|
|
17533
17318
|
compute: function (settlement, maturity, price) {
|
|
17534
17319
|
const start = Math.trunc(toNumber(settlement, this.locale));
|
|
17535
17320
|
const end = Math.trunc(toNumber(maturity, this.locale));
|
|
@@ -17569,7 +17354,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17569
17354
|
arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The number of months in the first year of depreciation.")),
|
|
17570
17355
|
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
17356
|
],
|
|
17572
|
-
returns: ["NUMBER"],
|
|
17573
17357
|
compute: function (cost, salvage, life, startPeriod, endPeriod, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }, noSwitch = { value: DEFAULT_VDB_NO_SWITCH }) {
|
|
17574
17358
|
factor = factor || 0;
|
|
17575
17359
|
const _cost = toNumber(cost, this.locale);
|
|
@@ -17634,7 +17418,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17634
17418
|
arg("cashflow_dates (range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
|
|
17635
17419
|
arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the internal rate of return will be.")),
|
|
17636
17420
|
],
|
|
17637
|
-
returns: ["NUMBER"],
|
|
17638
17421
|
compute: function (cashflowAmounts, cashflowDates, rateGuess = { value: RATE_GUESS_DEFAULT }) {
|
|
17639
17422
|
const guess = toNumber(rateGuess, this.locale);
|
|
17640
17423
|
const _cashFlows = cashflowAmounts.flat().map((val) => toNumber(val, this.locale));
|
|
@@ -17705,7 +17488,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17705
17488
|
arg("cashflow_amounts (number, range<number>)", _t("An range containing the income or payments associated with the investment.")),
|
|
17706
17489
|
arg("cashflow_dates (number, range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
|
|
17707
17490
|
],
|
|
17708
|
-
returns: ["NUMBER"],
|
|
17709
17491
|
compute: function (discount, cashflowAmounts, cashflowDates) {
|
|
17710
17492
|
const rate = toNumber(discount, this.locale);
|
|
17711
17493
|
const _cashFlows = isMatrix(cashflowAmounts)
|
|
@@ -17772,7 +17554,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17772
17554
|
arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
|
|
17773
17555
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17774
17556
|
],
|
|
17775
|
-
returns: ["NUMBER"],
|
|
17776
17557
|
compute: function (settlement, maturity, rate, price, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17777
17558
|
dayCountConvention = dayCountConvention || 0;
|
|
17778
17559
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17847,7 +17628,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17847
17628
|
arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
|
|
17848
17629
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17849
17630
|
],
|
|
17850
|
-
returns: ["NUMBER"],
|
|
17851
17631
|
compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17852
17632
|
dayCountConvention = dayCountConvention || 0;
|
|
17853
17633
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17884,7 +17664,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17884
17664
|
arg("price (number)", _t("The price at which the security is bought.")),
|
|
17885
17665
|
arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
|
|
17886
17666
|
],
|
|
17887
|
-
returns: ["NUMBER"],
|
|
17888
17667
|
compute: function (settlement, maturity, issue, rate, price, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
|
|
17889
17668
|
dayCountConvention = dayCountConvention || 0;
|
|
17890
17669
|
const _settlement = Math.trunc(toNumber(settlement, this.locale));
|
|
@@ -17971,7 +17750,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
17971
17750
|
arg("info_type (string)", _t("The type of information requested. Can be one of %s", CELL_INFO_TYPES.join(", "))),
|
|
17972
17751
|
arg("reference (meta)", _t("The reference to the cell.")),
|
|
17973
17752
|
],
|
|
17974
|
-
returns: ["ANY"],
|
|
17975
17753
|
compute: function (info, reference) {
|
|
17976
17754
|
const _info = toString(info).toLowerCase();
|
|
17977
17755
|
assert(() => CELL_INFO_TYPES.includes(_info), _t("The info_type should be one of %s.", CELL_INFO_TYPES.join(", ")));
|
|
@@ -18022,7 +17800,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18022
17800
|
const ISERR = {
|
|
18023
17801
|
description: _t("Whether a value is an error other than #N/A."),
|
|
18024
17802
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18025
|
-
returns: ["BOOLEAN"],
|
|
18026
17803
|
compute: function (data) {
|
|
18027
17804
|
const value = data?.value;
|
|
18028
17805
|
return isEvaluationError(value) && value !== CellErrorType.NotAvailable;
|
|
@@ -18035,7 +17812,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18035
17812
|
const ISERROR = {
|
|
18036
17813
|
description: _t("Whether a value is an error."),
|
|
18037
17814
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18038
|
-
returns: ["BOOLEAN"],
|
|
18039
17815
|
compute: function (data) {
|
|
18040
17816
|
const value = data?.value;
|
|
18041
17817
|
return isEvaluationError(value);
|
|
@@ -18048,7 +17824,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18048
17824
|
const ISLOGICAL = {
|
|
18049
17825
|
description: _t("Whether a value is `true` or `false`."),
|
|
18050
17826
|
args: [arg("value (any)", _t("The value to be verified as a logical TRUE or FALSE."))],
|
|
18051
|
-
returns: ["BOOLEAN"],
|
|
18052
17827
|
compute: function (value) {
|
|
18053
17828
|
return typeof value?.value === "boolean";
|
|
18054
17829
|
},
|
|
@@ -18060,7 +17835,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18060
17835
|
const ISNA = {
|
|
18061
17836
|
description: _t("Whether a value is the error #N/A."),
|
|
18062
17837
|
args: [arg("value (any)", _t("The value to be verified as an error type."))],
|
|
18063
|
-
returns: ["BOOLEAN"],
|
|
18064
17838
|
compute: function (data) {
|
|
18065
17839
|
return data?.value === CellErrorType.NotAvailable;
|
|
18066
17840
|
},
|
|
@@ -18072,7 +17846,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18072
17846
|
const ISNONTEXT = {
|
|
18073
17847
|
description: _t("Whether a value is non-textual."),
|
|
18074
17848
|
args: [arg("value (any)", _t("The value to be checked."))],
|
|
18075
|
-
returns: ["BOOLEAN"],
|
|
18076
17849
|
compute: function (value) {
|
|
18077
17850
|
return !ISTEXT.compute.bind(this)(value);
|
|
18078
17851
|
},
|
|
@@ -18084,7 +17857,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18084
17857
|
const ISNUMBER = {
|
|
18085
17858
|
description: _t("Whether a value is a number."),
|
|
18086
17859
|
args: [arg("value (any)", _t("The value to be verified as a number."))],
|
|
18087
|
-
returns: ["BOOLEAN"],
|
|
18088
17860
|
compute: function (value) {
|
|
18089
17861
|
return typeof value?.value === "number";
|
|
18090
17862
|
},
|
|
@@ -18096,7 +17868,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18096
17868
|
const ISTEXT = {
|
|
18097
17869
|
description: _t("Whether a value is text."),
|
|
18098
17870
|
args: [arg("value (any)", _t("The value to be verified as text."))],
|
|
18099
|
-
returns: ["BOOLEAN"],
|
|
18100
17871
|
compute: function (value) {
|
|
18101
17872
|
return typeof value?.value === "string" && isEvaluationError(value?.value) === false;
|
|
18102
17873
|
},
|
|
@@ -18108,7 +17879,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18108
17879
|
const ISBLANK = {
|
|
18109
17880
|
description: _t("Whether the referenced cell is empty"),
|
|
18110
17881
|
args: [arg("value (any)", _t("Reference to the cell that will be checked for emptiness."))],
|
|
18111
|
-
returns: ["BOOLEAN"],
|
|
18112
17882
|
compute: function (value) {
|
|
18113
17883
|
return value?.value === null;
|
|
18114
17884
|
},
|
|
@@ -18120,7 +17890,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18120
17890
|
const NA = {
|
|
18121
17891
|
description: _t("Returns the error value #N/A."),
|
|
18122
17892
|
args: [],
|
|
18123
|
-
returns: ["BOOLEAN"],
|
|
18124
17893
|
compute: function () {
|
|
18125
17894
|
return { value: CellErrorType.NotAvailable };
|
|
18126
17895
|
},
|
|
@@ -18177,7 +17946,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18177
17946
|
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
17947
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that represent logical values.")),
|
|
18179
17948
|
],
|
|
18180
|
-
returns: ["BOOLEAN"],
|
|
18181
17949
|
compute: function (...logicalExpressions) {
|
|
18182
17950
|
const { result, foundBoolean } = boolAnd(logicalExpressions);
|
|
18183
17951
|
assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
|
|
@@ -18191,7 +17959,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18191
17959
|
const FALSE = {
|
|
18192
17960
|
description: _t("Logical value `false`."),
|
|
18193
17961
|
args: [],
|
|
18194
|
-
returns: ["BOOLEAN"],
|
|
18195
17962
|
compute: function () {
|
|
18196
17963
|
return false;
|
|
18197
17964
|
},
|
|
@@ -18207,7 +17974,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18207
17974
|
arg("value_if_true (any)", _t("The value the function returns if logical_expression is TRUE.")),
|
|
18208
17975
|
arg("value_if_false (any, default=FALSE)", _t("The value the function returns if logical_expression is FALSE.")),
|
|
18209
17976
|
],
|
|
18210
|
-
returns: ["ANY"],
|
|
18211
17977
|
compute: function (logicalExpression, valueIfTrue, valueIfFalse) {
|
|
18212
17978
|
const result = toBoolean(logicalExpression?.value) ? valueIfTrue : valueIfFalse;
|
|
18213
17979
|
if (result === undefined) {
|
|
@@ -18229,7 +17995,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18229
17995
|
arg("value (any)", _t("The value to return if value itself is not an error.")),
|
|
18230
17996
|
arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an error.")),
|
|
18231
17997
|
],
|
|
18232
|
-
returns: ["ANY"],
|
|
18233
17998
|
compute: function (value, valueIfError = { value: "" }) {
|
|
18234
17999
|
const result = isEvaluationError(value?.value) ? valueIfError : value;
|
|
18235
18000
|
if (result === undefined) {
|
|
@@ -18251,7 +18016,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18251
18016
|
arg("value (any)", _t("The value to return if value itself is not #N/A an error.")),
|
|
18252
18017
|
arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an #N/A error.")),
|
|
18253
18018
|
],
|
|
18254
|
-
returns: ["ANY"],
|
|
18255
18019
|
compute: function (value, valueIfError = { value: "" }) {
|
|
18256
18020
|
const result = value?.value === CellErrorType.NotAvailable ? valueIfError : value;
|
|
18257
18021
|
if (result === undefined) {
|
|
@@ -18275,7 +18039,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18275
18039
|
arg("condition2 (boolean, repeating)", _t("Additional conditions to be evaluated if the previous ones are FALSE.")),
|
|
18276
18040
|
arg("value2 (any, repeating)", _t("Additional values to be returned if their corresponding conditions are TRUE.")),
|
|
18277
18041
|
],
|
|
18278
|
-
returns: ["ANY"],
|
|
18279
18042
|
compute: function (...values) {
|
|
18280
18043
|
assert(() => values.length % 2 === 0, _t("Wrong number of arguments. Expected an even number of arguments."));
|
|
18281
18044
|
for (let n = 0; n < values.length - 1; n += 2) {
|
|
@@ -18302,7 +18065,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18302
18065
|
args: [
|
|
18303
18066
|
arg("logical_expression (boolean)", _t("An expression or reference to a cell holding an expression that represents some logical value.")),
|
|
18304
18067
|
],
|
|
18305
|
-
returns: ["BOOLEAN"],
|
|
18306
18068
|
compute: function (logicalExpression) {
|
|
18307
18069
|
return !toBoolean(logicalExpression);
|
|
18308
18070
|
},
|
|
@@ -18317,7 +18079,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18317
18079
|
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
18080
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
|
|
18319
18081
|
],
|
|
18320
|
-
returns: ["BOOLEAN"],
|
|
18321
18082
|
compute: function (...logicalExpressions) {
|
|
18322
18083
|
const { result, foundBoolean } = boolOr(logicalExpressions);
|
|
18323
18084
|
assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
|
|
@@ -18331,7 +18092,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18331
18092
|
const TRUE = {
|
|
18332
18093
|
description: _t("Logical value `true`."),
|
|
18333
18094
|
args: [],
|
|
18334
|
-
returns: ["BOOLEAN"],
|
|
18335
18095
|
compute: function () {
|
|
18336
18096
|
return true;
|
|
18337
18097
|
},
|
|
@@ -18346,7 +18106,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18346
18106
|
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
18107
|
arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
|
|
18348
18108
|
],
|
|
18349
|
-
returns: ["BOOLEAN"],
|
|
18350
18109
|
compute: function (...logicalExpressions) {
|
|
18351
18110
|
let foundBoolean = false;
|
|
18352
18111
|
let acc = false;
|
|
@@ -18375,9 +18134,229 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18375
18134
|
XOR: XOR
|
|
18376
18135
|
});
|
|
18377
18136
|
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18137
|
+
const pivotTimeAdapterRegistry = new Registry();
|
|
18138
|
+
function pivotTimeAdapter(granularity) {
|
|
18139
|
+
return pivotTimeAdapterRegistry.get(granularity);
|
|
18140
|
+
}
|
|
18141
|
+
/**
|
|
18142
|
+
* The Time Adapter: Managing Time Periods for Pivot Functions
|
|
18143
|
+
*
|
|
18144
|
+
* Overview:
|
|
18145
|
+
* A time adapter is responsible for managing time periods associated with pivot functions.
|
|
18146
|
+
* Each type of period (day, week, month, quarter, etc.) has its own dedicated adapter.
|
|
18147
|
+
* The adapter's primary role is to normalize period values between spreadsheet functions,
|
|
18148
|
+
* and the pivot.
|
|
18149
|
+
* By normalizing the period value, it can be stored consistently in the pivot.
|
|
18150
|
+
*
|
|
18151
|
+
* Normalization Process:
|
|
18152
|
+
* When working with functions in the spreadsheet, the time adapter normalizes
|
|
18153
|
+
* the provided period to facilitate accurate lookup of values in the pivot.
|
|
18154
|
+
* For instance, if the spreadsheet function represents a day period as a number generated
|
|
18155
|
+
* by the DATE function (DATE(2023, 12, 25)), the time adapter will normalize it accordingly.
|
|
18156
|
+
*
|
|
18157
|
+
*/
|
|
18158
|
+
/**
|
|
18159
|
+
* Normalized value: "12/25/2023"
|
|
18160
|
+
*
|
|
18161
|
+
* Note: Those two format are equivalent:
|
|
18162
|
+
* - "MM/dd/yyyy" (luxon format)
|
|
18163
|
+
* - "mm/dd/yyyy" (spreadsheet format)
|
|
18164
|
+
**/
|
|
18165
|
+
const dayAdapter = {
|
|
18166
|
+
normalizeFunctionValue(value) {
|
|
18167
|
+
const date = toNumber(value, DEFAULT_LOCALE);
|
|
18168
|
+
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/dd/yyyy" });
|
|
18169
|
+
},
|
|
18170
|
+
getFormat(locale) {
|
|
18171
|
+
return (locale ?? DEFAULT_LOCALE).dateFormat;
|
|
18172
|
+
},
|
|
18173
|
+
formatValue(normalizedValue, locale) {
|
|
18174
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18175
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18176
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18177
|
+
},
|
|
18178
|
+
toCellValue(normalizedValue) {
|
|
18179
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18180
|
+
},
|
|
18181
|
+
};
|
|
18182
|
+
/**
|
|
18183
|
+
* normalizes day of month number
|
|
18184
|
+
*/
|
|
18185
|
+
const dayOfMonthAdapter = {
|
|
18186
|
+
normalizeFunctionValue(value) {
|
|
18187
|
+
const day = toNumber(value, DEFAULT_LOCALE);
|
|
18188
|
+
if (day < 1 || day > 31) {
|
|
18189
|
+
throw new EvaluationError(_t("%s is not a valid day of month (it should be a number between 1 and 31)", day));
|
|
18190
|
+
}
|
|
18191
|
+
return day;
|
|
18192
|
+
},
|
|
18193
|
+
getFormat() {
|
|
18194
|
+
return "0";
|
|
18195
|
+
},
|
|
18196
|
+
formatValue(normalizedValue, locale) {
|
|
18197
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18198
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18199
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18200
|
+
},
|
|
18201
|
+
toCellValue(normalizedValue) {
|
|
18202
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18203
|
+
},
|
|
18204
|
+
};
|
|
18205
|
+
/**
|
|
18206
|
+
* Normalized value: "2/2023" for week 2 of 2023
|
|
18207
|
+
*/
|
|
18208
|
+
const weekAdapter = {
|
|
18209
|
+
normalizeFunctionValue(value) {
|
|
18210
|
+
const [week, year] = value.split("/");
|
|
18211
|
+
return `${Number(week)}/${Number(year)}`;
|
|
18212
|
+
},
|
|
18213
|
+
getFormat() {
|
|
18214
|
+
return undefined;
|
|
18215
|
+
},
|
|
18216
|
+
formatValue(normalizedValue) {
|
|
18217
|
+
const [week, year] = normalizedValue.split("/");
|
|
18218
|
+
return _t("W%(week)s %(year)s", { week, year });
|
|
18219
|
+
},
|
|
18220
|
+
toCellValue(normalizedValue) {
|
|
18221
|
+
return this.formatValue(normalizedValue);
|
|
18222
|
+
},
|
|
18223
|
+
};
|
|
18224
|
+
/**
|
|
18225
|
+
* normalizes iso week number
|
|
18226
|
+
*/
|
|
18227
|
+
const isoWeekNumberAdapter = {
|
|
18228
|
+
normalizeFunctionValue(value) {
|
|
18229
|
+
const isoWeek = toNumber(value, DEFAULT_LOCALE);
|
|
18230
|
+
if (isoWeek < 0 || isoWeek > 53) {
|
|
18231
|
+
throw new EvaluationError(_t("%s is not a valid week (it should be a number between 0 and 53)", isoWeek));
|
|
18232
|
+
}
|
|
18233
|
+
return isoWeek;
|
|
18234
|
+
},
|
|
18235
|
+
getFormat() {
|
|
18236
|
+
return "0";
|
|
18237
|
+
},
|
|
18238
|
+
formatValue(normalizedValue, locale) {
|
|
18239
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18240
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18241
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18242
|
+
},
|
|
18243
|
+
toCellValue(normalizedValue) {
|
|
18244
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18245
|
+
},
|
|
18246
|
+
};
|
|
18247
|
+
/**
|
|
18248
|
+
* normalized month value is a string formatted as "MM/yyyy" (luxon format)
|
|
18249
|
+
* e.g. "01/2020" for January 2020
|
|
18250
|
+
*/
|
|
18251
|
+
const monthAdapter = {
|
|
18252
|
+
normalizeFunctionValue(value) {
|
|
18253
|
+
const date = toNumber(value, DEFAULT_LOCALE);
|
|
18254
|
+
return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
|
|
18255
|
+
},
|
|
18256
|
+
getFormat() {
|
|
18257
|
+
return "mmmm yyyy";
|
|
18258
|
+
},
|
|
18259
|
+
formatValue(normalizedValue, locale) {
|
|
18260
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18261
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18262
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18263
|
+
},
|
|
18264
|
+
toCellValue(normalizedValue) {
|
|
18265
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18266
|
+
},
|
|
18267
|
+
};
|
|
18268
|
+
/**
|
|
18269
|
+
* normalizes month number
|
|
18270
|
+
*/
|
|
18271
|
+
const monthNumberAdapter = {
|
|
18272
|
+
normalizeFunctionValue(value) {
|
|
18273
|
+
const month = toNumber(value, DEFAULT_LOCALE);
|
|
18274
|
+
if (month < 1 || month > 12) {
|
|
18275
|
+
throw new EvaluationError(_t("%s is not a valid month (it should be a number between 1 and 12)", month));
|
|
18276
|
+
}
|
|
18277
|
+
return month;
|
|
18278
|
+
},
|
|
18279
|
+
getFormat() {
|
|
18280
|
+
return "0";
|
|
18281
|
+
},
|
|
18282
|
+
formatValue(normalizedValue, locale) {
|
|
18283
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18284
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18285
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18286
|
+
},
|
|
18287
|
+
toCellValue(normalizedValue) {
|
|
18288
|
+
return MONTHS[toNumber(normalizedValue, DEFAULT_LOCALE) - 1].toString();
|
|
18289
|
+
},
|
|
18290
|
+
};
|
|
18291
|
+
/**
|
|
18292
|
+
* normalized quarter value is "quarter/year"
|
|
18293
|
+
* e.g. "1/2020" for Q1 2020
|
|
18294
|
+
*/
|
|
18295
|
+
const quarterAdapter = {
|
|
18296
|
+
normalizeFunctionValue(value) {
|
|
18297
|
+
const [quarter, year] = value.split("/");
|
|
18298
|
+
return `${quarter}/${year}`;
|
|
18299
|
+
},
|
|
18300
|
+
getFormat() {
|
|
18301
|
+
return undefined;
|
|
18302
|
+
},
|
|
18303
|
+
formatValue(normalizedValue) {
|
|
18304
|
+
const [quarter, year] = normalizedValue.split("/");
|
|
18305
|
+
return _t("Q%(quarter)s %(year)s", { quarter, year });
|
|
18306
|
+
},
|
|
18307
|
+
toCellValue(normalizedValue) {
|
|
18308
|
+
return this.formatValue(normalizedValue);
|
|
18309
|
+
},
|
|
18310
|
+
};
|
|
18311
|
+
/**
|
|
18312
|
+
* normalizes quarter number
|
|
18313
|
+
*/
|
|
18314
|
+
const quarterNumberAdapter = {
|
|
18315
|
+
normalizeFunctionValue(value) {
|
|
18316
|
+
const quarter = toNumber(value, DEFAULT_LOCALE);
|
|
18317
|
+
if (quarter < 1 || quarter > 4) {
|
|
18318
|
+
throw new EvaluationError(_t("%s is not a valid quarter (it should be a number between 1 and 4)", quarter));
|
|
18319
|
+
}
|
|
18320
|
+
return quarter;
|
|
18321
|
+
},
|
|
18322
|
+
getFormat() {
|
|
18323
|
+
return "0";
|
|
18324
|
+
},
|
|
18325
|
+
formatValue(normalizedValue, locale) {
|
|
18326
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18327
|
+
const value = toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18328
|
+
return formatValue(value, { locale, format: this.getFormat(locale) });
|
|
18329
|
+
},
|
|
18330
|
+
toCellValue(normalizedValue) {
|
|
18331
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18332
|
+
},
|
|
18333
|
+
};
|
|
18334
|
+
const yearAdapter = {
|
|
18335
|
+
normalizeFunctionValue(value) {
|
|
18336
|
+
return toNumber(value, DEFAULT_LOCALE);
|
|
18337
|
+
},
|
|
18338
|
+
getFormat() {
|
|
18339
|
+
return "0";
|
|
18340
|
+
},
|
|
18341
|
+
formatValue(normalizedValue, locale) {
|
|
18342
|
+
locale = locale ?? DEFAULT_LOCALE;
|
|
18343
|
+
return formatValue(normalizedValue, { locale, format: "0" });
|
|
18344
|
+
},
|
|
18345
|
+
toCellValue(normalizedValue) {
|
|
18346
|
+
return toNumber(normalizedValue, DEFAULT_LOCALE);
|
|
18347
|
+
},
|
|
18348
|
+
};
|
|
18349
|
+
pivotTimeAdapterRegistry
|
|
18350
|
+
.add("day", dayAdapter)
|
|
18351
|
+
.add("week", weekAdapter)
|
|
18352
|
+
.add("month", monthAdapter)
|
|
18353
|
+
.add("quarter", quarterAdapter)
|
|
18354
|
+
.add("year", yearAdapter)
|
|
18355
|
+
.add("day_of_month", dayOfMonthAdapter)
|
|
18356
|
+
.add("iso_week_number", isoWeekNumberAdapter)
|
|
18357
|
+
.add("month_number", monthNumberAdapter)
|
|
18358
|
+
.add("quarter_number", quarterNumberAdapter)
|
|
18359
|
+
.add("year_number", yearAdapter);
|
|
18381
18360
|
|
|
18382
18361
|
const AGGREGATOR_NAMES = {
|
|
18383
18362
|
count: _t("Count"),
|
|
@@ -18393,7 +18372,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18393
18372
|
const AGGREGATORS_BY_FIELD_TYPE = {
|
|
18394
18373
|
integer: NUMBER_CHAR_AGGREGATORS,
|
|
18395
18374
|
char: NUMBER_CHAR_AGGREGATORS,
|
|
18396
|
-
|
|
18375
|
+
boolean: ["count_distinct", "count", "bool_and", "bool_or"],
|
|
18397
18376
|
};
|
|
18398
18377
|
const AGGREGATORS = {};
|
|
18399
18378
|
for (const type in AGGREGATORS_BY_FIELD_TYPE) {
|
|
@@ -18503,6 +18482,44 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18503
18482
|
function flatPivotDomain(domain) {
|
|
18504
18483
|
return domain.flatMap((arg) => [arg.field, arg.value]);
|
|
18505
18484
|
}
|
|
18485
|
+
/**
|
|
18486
|
+
* Parses the value defining a pivot group in a PIVOT formula
|
|
18487
|
+
* e.g. given the following formula PIVOT.VALUE("1", "stage_id", "42", "status", "won"),
|
|
18488
|
+
* the two group values are "42" and "won".
|
|
18489
|
+
*/
|
|
18490
|
+
function toNormalizedPivotValue(dimension, groupValue) {
|
|
18491
|
+
if (groupValue === null || groupValue === "null") {
|
|
18492
|
+
return null;
|
|
18493
|
+
}
|
|
18494
|
+
const groupValueString = typeof groupValue === "boolean"
|
|
18495
|
+
? toString(groupValue).toLocaleLowerCase()
|
|
18496
|
+
: toString(groupValue);
|
|
18497
|
+
if (!pivotNormalizationValueRegistry.contains(dimension.type)) {
|
|
18498
|
+
throw new EvaluationError(_t("Field %(field)s is not supported because of its type (%(type)s)", {
|
|
18499
|
+
field: dimension.displayName,
|
|
18500
|
+
type: dimension.type,
|
|
18501
|
+
}));
|
|
18502
|
+
}
|
|
18503
|
+
// represents a field which is not set (=False server side)
|
|
18504
|
+
if (groupValueString === "false") {
|
|
18505
|
+
return false;
|
|
18506
|
+
}
|
|
18507
|
+
const normalizer = pivotNormalizationValueRegistry.get(dimension.type);
|
|
18508
|
+
return normalizer(groupValueString, dimension.granularity);
|
|
18509
|
+
}
|
|
18510
|
+
function normalizeDateTime(value, granularity) {
|
|
18511
|
+
if (!granularity) {
|
|
18512
|
+
throw "";
|
|
18513
|
+
}
|
|
18514
|
+
return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
|
|
18515
|
+
}
|
|
18516
|
+
const pivotNormalizationValueRegistry = new Registry();
|
|
18517
|
+
pivotNormalizationValueRegistry
|
|
18518
|
+
.add("date", normalizeDateTime)
|
|
18519
|
+
.add("datetime", normalizeDateTime)
|
|
18520
|
+
.add("integer", (value) => toNumber(value, DEFAULT_LOCALE))
|
|
18521
|
+
.add("boolean", (value) => toBoolean(value))
|
|
18522
|
+
.add("char", (value) => toString(value));
|
|
18506
18523
|
|
|
18507
18524
|
/**
|
|
18508
18525
|
* Get the pivot ID from the formula pivot ID.
|
|
@@ -18579,7 +18596,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18579
18596
|
arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
|
|
18580
18597
|
arg("sheet (string, optional)", _t("A string indicating the name of the sheet into which the address points.")),
|
|
18581
18598
|
],
|
|
18582
|
-
returns: ["STRING"],
|
|
18583
18599
|
compute: function (row, column, absoluteRelativeMode = { value: DEFAULT_ABSOLUTE_RELATIVE_MODE }, useA1Notation = { value: true }, sheet) {
|
|
18584
18600
|
const rowNumber = strictToInteger(row, this.locale);
|
|
18585
18601
|
const colNumber = strictToInteger(column, this.locale);
|
|
@@ -18616,7 +18632,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18616
18632
|
args: [
|
|
18617
18633
|
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
18634
|
],
|
|
18619
|
-
returns: ["NUMBER"],
|
|
18620
18635
|
compute: function (cellReference) {
|
|
18621
18636
|
if (isEvaluationError(cellReference?.value)) {
|
|
18622
18637
|
throw cellReference;
|
|
@@ -18634,7 +18649,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18634
18649
|
const COLUMNS = {
|
|
18635
18650
|
description: _t("Number of columns in a specified array or range."),
|
|
18636
18651
|
args: [arg("range (meta)", _t("The range whose column count will be returned."))],
|
|
18637
|
-
returns: ["NUMBER"],
|
|
18638
18652
|
compute: function (range) {
|
|
18639
18653
|
if (isEvaluationError(range?.value)) {
|
|
18640
18654
|
throw range;
|
|
@@ -18655,7 +18669,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18655
18669
|
arg("index (number)", _t("The row index of the value to be returned, where the first row in range is numbered 1.")),
|
|
18656
18670
|
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
18671
|
],
|
|
18658
|
-
returns: ["ANY"],
|
|
18659
18672
|
compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18660
18673
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18661
18674
|
assert(() => 1 <= _index && _index <= range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
@@ -18685,7 +18698,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18685
18698
|
arg("row (number, default=0)", _t("The index of the row to be returned from within the reference range of cells.")),
|
|
18686
18699
|
arg("column (number, default=0)", _t("The index of the column to be returned from within the reference range of cells.")),
|
|
18687
18700
|
],
|
|
18688
|
-
returns: ["ANY"],
|
|
18689
18701
|
compute: function (reference, row = { value: 0 }, column = { value: 0 }) {
|
|
18690
18702
|
const _reference = toMatrix(reference);
|
|
18691
18703
|
const _row = toNumber(row.value, this.locale);
|
|
@@ -18716,7 +18728,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18716
18728
|
arg("reference (string)", _t("The range of cells from which the values are returned.")),
|
|
18717
18729
|
arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
|
|
18718
18730
|
],
|
|
18719
|
-
returns: ["ANY"],
|
|
18720
18731
|
compute: function (reference, useA1Notation = { value: true }) {
|
|
18721
18732
|
let _reference = reference?.value?.toString();
|
|
18722
18733
|
if (!_reference) {
|
|
@@ -18771,7 +18782,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18771
18782
|
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
18783
|
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
18784
|
],
|
|
18774
|
-
returns: ["ANY"],
|
|
18775
18785
|
compute: function (searchKey, searchArray, resultRange) {
|
|
18776
18786
|
let nbCol = searchArray.length;
|
|
18777
18787
|
let nbRow = searchArray[0].length;
|
|
@@ -18812,7 +18822,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18812
18822
|
arg("range (any, range)", _t("The one-dimensional array to be searched.")),
|
|
18813
18823
|
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
18824
|
],
|
|
18815
|
-
returns: ["NUMBER"],
|
|
18816
18825
|
compute: function (searchKey, range, searchType = { value: DEFAULT_SEARCH_TYPE }) {
|
|
18817
18826
|
let _searchType = toNumber(searchType, this.locale);
|
|
18818
18827
|
const nbCol = range.length;
|
|
@@ -18851,7 +18860,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18851
18860
|
args: [
|
|
18852
18861
|
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
18862
|
],
|
|
18854
|
-
returns: ["NUMBER"],
|
|
18855
18863
|
compute: function (cellReference) {
|
|
18856
18864
|
if (isEvaluationError(cellReference?.value)) {
|
|
18857
18865
|
throw cellReference;
|
|
@@ -18869,7 +18877,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18869
18877
|
const ROWS = {
|
|
18870
18878
|
description: _t("Number of rows in a specified array or range."),
|
|
18871
18879
|
args: [arg("range (meta)", _t("The range whose row count will be returned."))],
|
|
18872
|
-
returns: ["NUMBER"],
|
|
18873
18880
|
compute: function (range) {
|
|
18874
18881
|
if (isEvaluationError(range?.value)) {
|
|
18875
18882
|
throw range;
|
|
@@ -18890,7 +18897,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18890
18897
|
arg("index (number)", _t("The column index of the value to be returned, where the first column in range is numbered 1.")),
|
|
18891
18898
|
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
18899
|
],
|
|
18893
|
-
returns: ["ANY"],
|
|
18894
18900
|
compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
|
|
18895
18901
|
const _index = Math.trunc(toNumber(index?.value, this.locale));
|
|
18896
18902
|
assert(() => 1 <= _index && _index <= range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
|
|
@@ -18936,7 +18942,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18936
18942
|
(-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned.\
|
|
18937
18943
|
")),
|
|
18938
18944
|
],
|
|
18939
|
-
returns: ["ANY"],
|
|
18940
18945
|
compute: function (searchKey, lookupRange, returnRange, defaultValue, matchMode = { value: DEFAULT_MATCH_MODE }, searchMode = { value: DEFAULT_SEARCH_MODE }) {
|
|
18941
18946
|
const _matchMode = Math.trunc(toNumber(matchMode.value, this.locale));
|
|
18942
18947
|
const _searchMode = Math.trunc(toNumber(searchMode.value, this.locale));
|
|
@@ -18992,12 +18997,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
18992
18997
|
assertDomainLength(_domainArgs);
|
|
18993
18998
|
const pivot = this.getters.getPivot(pivotId);
|
|
18994
18999
|
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
19000
|
addPivotDependencies(this, coreDefinition);
|
|
19002
19001
|
const error = pivot.assertIsValid({ throwOnError: false });
|
|
19003
19002
|
if (error) {
|
|
@@ -19013,7 +19012,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19013
19012
|
}
|
|
19014
19013
|
return { value, format };
|
|
19015
19014
|
},
|
|
19016
|
-
returns: ["NUMBER", "STRING"],
|
|
19017
19015
|
};
|
|
19018
19016
|
const PIVOT_HEADER = {
|
|
19019
19017
|
description: _t("Get the header of a pivot."),
|
|
@@ -19029,12 +19027,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19029
19027
|
assertDomainLength(_domainArgs);
|
|
19030
19028
|
const pivot = this.getters.getPivot(_pivotId);
|
|
19031
19029
|
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
19030
|
addPivotDependencies(this, coreDefinition);
|
|
19039
19031
|
const error = pivot.assertIsValid({ throwOnError: false });
|
|
19040
19032
|
if (error) {
|
|
@@ -19059,7 +19051,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19059
19051
|
: format,
|
|
19060
19052
|
};
|
|
19061
19053
|
},
|
|
19062
|
-
returns: ["NUMBER", "STRING"],
|
|
19063
19054
|
};
|
|
19064
19055
|
const PIVOT = {
|
|
19065
19056
|
description: _t("Get a pivot table."),
|
|
@@ -19126,7 +19117,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19126
19117
|
}
|
|
19127
19118
|
return result;
|
|
19128
19119
|
},
|
|
19129
|
-
returns: ["RANGE<ANY>"],
|
|
19130
19120
|
};
|
|
19131
19121
|
|
|
19132
19122
|
var lookup = /*#__PURE__*/Object.freeze({
|
|
@@ -19157,7 +19147,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19157
19147
|
arg("value1 (number)", _t("The first addend.")),
|
|
19158
19148
|
arg("value2 (number)", _t("The second addend.")),
|
|
19159
19149
|
],
|
|
19160
|
-
returns: ["NUMBER"],
|
|
19161
19150
|
compute: function (value1, value2) {
|
|
19162
19151
|
return {
|
|
19163
19152
|
value: toNumber(value1, this.locale) + toNumber(value2, this.locale),
|
|
@@ -19174,7 +19163,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19174
19163
|
arg("value1 (string)", _t("The value to which value2 will be appended.")),
|
|
19175
19164
|
arg("value2 (string)", _t("The value to append to value1.")),
|
|
19176
19165
|
],
|
|
19177
|
-
returns: ["STRING"],
|
|
19178
19166
|
compute: function (value1, value2) {
|
|
19179
19167
|
return toString(value1) + toString(value2);
|
|
19180
19168
|
},
|
|
@@ -19189,7 +19177,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19189
19177
|
arg("dividend (number)", _t("The number to be divided.")),
|
|
19190
19178
|
arg("divisor (number)", _t("The number to divide by.")),
|
|
19191
19179
|
],
|
|
19192
|
-
returns: ["NUMBER"],
|
|
19193
19180
|
compute: function (dividend, divisor) {
|
|
19194
19181
|
const _divisor = toNumber(divisor, this.locale);
|
|
19195
19182
|
assert(() => _divisor !== 0, _t("The divisor must be different from zero."), CellErrorType.DivisionByZero);
|
|
@@ -19212,7 +19199,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19212
19199
|
arg("value1 (any)", _t("The first value.")),
|
|
19213
19200
|
arg("value2 (any)", _t("The value to test against value1 for equality.")),
|
|
19214
19201
|
],
|
|
19215
|
-
returns: ["BOOLEAN"],
|
|
19216
19202
|
compute: function (value1, value2) {
|
|
19217
19203
|
let _value1 = isEmpty(value1) ? getNeutral[typeof value2?.value] : value1?.value;
|
|
19218
19204
|
let _value2 = isEmpty(value2) ? getNeutral[typeof value1?.value] : value2?.value;
|
|
@@ -19265,7 +19251,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19265
19251
|
arg("value1 (any)", _t("The value to test as being greater than value2.")),
|
|
19266
19252
|
arg("value2 (any)", _t("The second value.")),
|
|
19267
19253
|
],
|
|
19268
|
-
returns: ["BOOLEAN"],
|
|
19269
19254
|
compute: function (value1, value2) {
|
|
19270
19255
|
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
19271
19256
|
return v1 > v2;
|
|
@@ -19281,7 +19266,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19281
19266
|
arg("value1 (any)", _t("The value to test as being greater than or equal to value2.")),
|
|
19282
19267
|
arg("value2 (any)", _t("The second value.")),
|
|
19283
19268
|
],
|
|
19284
|
-
returns: ["BOOLEAN"],
|
|
19285
19269
|
compute: function (value1, value2) {
|
|
19286
19270
|
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
19287
19271
|
return v1 >= v2;
|
|
@@ -19297,7 +19281,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19297
19281
|
arg("value1 (any)", _t("The value to test as being less than value2.")),
|
|
19298
19282
|
arg("value2 (any)", _t("The second value.")),
|
|
19299
19283
|
],
|
|
19300
|
-
returns: ["BOOLEAN"],
|
|
19301
19284
|
compute: function (value1, value2) {
|
|
19302
19285
|
return !GTE.compute.bind(this)(value1, value2);
|
|
19303
19286
|
},
|
|
@@ -19311,7 +19294,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19311
19294
|
arg("value1 (any)", _t("The value to test as being less than or equal to value2.")),
|
|
19312
19295
|
arg("value2 (any)", _t("The second value.")),
|
|
19313
19296
|
],
|
|
19314
|
-
returns: ["BOOLEAN"],
|
|
19315
19297
|
compute: function (value1, value2) {
|
|
19316
19298
|
return !GT.compute.bind(this)(value1, value2);
|
|
19317
19299
|
},
|
|
@@ -19325,7 +19307,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19325
19307
|
arg("value1 (number)", _t("The minuend, or number to be subtracted from.")),
|
|
19326
19308
|
arg("value2 (number)", _t("The subtrahend, or number to subtract from value1.")),
|
|
19327
19309
|
],
|
|
19328
|
-
returns: ["NUMBER"],
|
|
19329
19310
|
compute: function (value1, value2) {
|
|
19330
19311
|
return {
|
|
19331
19312
|
value: toNumber(value1, this.locale) - toNumber(value2, this.locale),
|
|
@@ -19342,7 +19323,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19342
19323
|
arg("factor1 (number)", _t("The first multiplicand.")),
|
|
19343
19324
|
arg("factor2 (number)", _t("The second multiplicand.")),
|
|
19344
19325
|
],
|
|
19345
|
-
returns: ["NUMBER"],
|
|
19346
19326
|
compute: function (factor1, factor2) {
|
|
19347
19327
|
return {
|
|
19348
19328
|
value: toNumber(factor1, this.locale) * toNumber(factor2, this.locale),
|
|
@@ -19359,7 +19339,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19359
19339
|
arg("value1 (any)", _t("The first value.")),
|
|
19360
19340
|
arg("value2 (any)", _t("The value to test against value1 for inequality.")),
|
|
19361
19341
|
],
|
|
19362
|
-
returns: ["BOOLEAN"],
|
|
19363
19342
|
compute: function (value1, value2) {
|
|
19364
19343
|
return !EQ.compute.bind(this)(value1, value2);
|
|
19365
19344
|
},
|
|
@@ -19373,7 +19352,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19373
19352
|
arg("base (number)", _t("The number to raise to the exponent power.")),
|
|
19374
19353
|
arg("exponent (number)", _t("The exponent to raise base to.")),
|
|
19375
19354
|
],
|
|
19376
|
-
returns: ["NUMBER"],
|
|
19377
19355
|
compute: function (base, exponent) {
|
|
19378
19356
|
return POWER.compute.bind(this)(base, exponent);
|
|
19379
19357
|
},
|
|
@@ -19386,7 +19364,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19386
19364
|
args: [
|
|
19387
19365
|
arg("value (number)", _t("The number to have its sign reversed. Equivalently, the number to multiply by -1.")),
|
|
19388
19366
|
],
|
|
19389
|
-
returns: ["NUMBER"],
|
|
19390
19367
|
compute: function (value) {
|
|
19391
19368
|
return {
|
|
19392
19369
|
value: -toNumber(value, this.locale),
|
|
@@ -19400,7 +19377,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19400
19377
|
const UNARY_PERCENT = {
|
|
19401
19378
|
description: _t("Value interpreted as a percentage."),
|
|
19402
19379
|
args: [arg("percentage (number)", _t("The value to interpret as a percentage."))],
|
|
19403
|
-
returns: ["NUMBER"],
|
|
19404
19380
|
compute: function (percentage) {
|
|
19405
19381
|
return toNumber(percentage, this.locale) / 100;
|
|
19406
19382
|
},
|
|
@@ -19411,7 +19387,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19411
19387
|
const UPLUS = {
|
|
19412
19388
|
description: _t("A specified number, unchanged."),
|
|
19413
19389
|
args: [arg("value (any)", _t("The number to return."))],
|
|
19414
|
-
returns: ["ANY"],
|
|
19415
19390
|
compute: function (value = { value: null }) {
|
|
19416
19391
|
return value;
|
|
19417
19392
|
},
|
|
@@ -19447,7 +19422,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19447
19422
|
args: [
|
|
19448
19423
|
arg("table_number (number)", _t("The number of the character to look up from the current Unicode table in decimal format.")),
|
|
19449
19424
|
],
|
|
19450
|
-
returns: ["STRING"],
|
|
19451
19425
|
compute: function (tableNumber) {
|
|
19452
19426
|
const _tableNumber = Math.trunc(toNumber(tableNumber, this.locale));
|
|
19453
19427
|
assert(() => _tableNumber >= 1, _t("The table_number (%s) is out of range.", _tableNumber.toString()));
|
|
@@ -19461,7 +19435,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19461
19435
|
const CLEAN = {
|
|
19462
19436
|
description: _t("Remove non-printable characters from a piece of text."),
|
|
19463
19437
|
args: [arg("text (string)", _t("The text whose non-printable characters are to be removed."))],
|
|
19464
|
-
returns: ["STRING"],
|
|
19465
19438
|
compute: function (text) {
|
|
19466
19439
|
const _text = toString(text);
|
|
19467
19440
|
let cleanedStr = "";
|
|
@@ -19483,7 +19456,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19483
19456
|
arg("string1 (string, range<string>)", _t("The initial string.")),
|
|
19484
19457
|
arg("string2 (string, range<string>, repeating)", _t("More strings to append in sequence.")),
|
|
19485
19458
|
],
|
|
19486
|
-
returns: ["STRING"],
|
|
19487
19459
|
compute: function (...datas) {
|
|
19488
19460
|
return reduceAny(datas, (acc, a) => acc + toString(a), "");
|
|
19489
19461
|
},
|
|
@@ -19498,7 +19470,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19498
19470
|
arg("string1 (string)", _t("The first string to compare.")),
|
|
19499
19471
|
arg("string2 (string)", _t("The second string to compare.")),
|
|
19500
19472
|
],
|
|
19501
|
-
returns: ["BOOLEAN"],
|
|
19502
19473
|
compute: function (string1, string2) {
|
|
19503
19474
|
return toString(string1) === toString(string2);
|
|
19504
19475
|
},
|
|
@@ -19514,7 +19485,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19514
19485
|
arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
|
|
19515
19486
|
arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
|
|
19516
19487
|
],
|
|
19517
|
-
returns: ["NUMBER"],
|
|
19518
19488
|
compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
|
|
19519
19489
|
const _searchFor = toString(searchFor);
|
|
19520
19490
|
const _textToSearch = toString(textToSearch);
|
|
@@ -19537,7 +19507,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19537
19507
|
arg("value_or_array1 (string, range<string>)", _t("The value or values to be appended using delimiter.")),
|
|
19538
19508
|
arg("value_or_array2 (string, range<string>, repeating)", _t("More values to be appended using delimiter.")),
|
|
19539
19509
|
],
|
|
19540
|
-
returns: ["STRING"],
|
|
19541
19510
|
compute: function (delimiter, ...valuesOrArrays) {
|
|
19542
19511
|
const _delimiter = toString(delimiter);
|
|
19543
19512
|
return reduceAny(valuesOrArrays, (acc, a) => (acc ? acc + _delimiter : "") + toString(a), "");
|
|
@@ -19552,7 +19521,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19552
19521
|
arg("text (string)", _t("The string from which the left portion will be returned.")),
|
|
19553
19522
|
arg("number_of_characters (number, optional)", _t("The number of characters to return from the left side of string.")),
|
|
19554
19523
|
],
|
|
19555
|
-
returns: ["STRING"],
|
|
19556
19524
|
compute: function (text, ...args) {
|
|
19557
19525
|
const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
|
|
19558
19526
|
assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
|
|
@@ -19566,7 +19534,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19566
19534
|
const LEN = {
|
|
19567
19535
|
description: _t("Length of a string."),
|
|
19568
19536
|
args: [arg("text (string)", _t("The string whose length will be returned."))],
|
|
19569
|
-
returns: ["NUMBER"],
|
|
19570
19537
|
compute: function (text) {
|
|
19571
19538
|
return toString(text).length;
|
|
19572
19539
|
},
|
|
@@ -19578,7 +19545,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19578
19545
|
const LOWER = {
|
|
19579
19546
|
description: _t("Converts a specified string to lowercase."),
|
|
19580
19547
|
args: [arg("text (string)", _t("The string to convert to lowercase."))],
|
|
19581
|
-
returns: ["STRING"],
|
|
19582
19548
|
compute: function (text) {
|
|
19583
19549
|
return toString(text).toLowerCase();
|
|
19584
19550
|
},
|
|
@@ -19594,7 +19560,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19594
19560
|
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
19561
|
arg("extract_length (number)", _t("The length of the segment to extract.")),
|
|
19596
19562
|
],
|
|
19597
|
-
returns: ["STRING"],
|
|
19598
19563
|
compute: function (text, starting_at, extract_length) {
|
|
19599
19564
|
const _text = toString(text);
|
|
19600
19565
|
const _starting_at = toNumber(starting_at, this.locale);
|
|
@@ -19613,7 +19578,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19613
19578
|
args: [
|
|
19614
19579
|
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
19580
|
],
|
|
19616
|
-
returns: ["STRING"],
|
|
19617
19581
|
compute: function (text) {
|
|
19618
19582
|
const _text = toString(text);
|
|
19619
19583
|
return _text.replace(wordRegex, (word) => {
|
|
@@ -19633,7 +19597,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19633
19597
|
arg("length (number)", _t("The number of characters in the text to be replaced.")),
|
|
19634
19598
|
arg("new_text (string)", _t("The text which will be inserted into the original text.")),
|
|
19635
19599
|
],
|
|
19636
|
-
returns: ["STRING"],
|
|
19637
19600
|
compute: function (text, position, length, newText) {
|
|
19638
19601
|
const _position = toNumber(position, this.locale);
|
|
19639
19602
|
assert(() => _position >= 1, _t("The position (%s) must be greater than or equal to 1.", _position.toString()));
|
|
@@ -19653,7 +19616,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19653
19616
|
arg("text (string)", _t("The string from which the right portion will be returned.")),
|
|
19654
19617
|
arg("number_of_characters (number, optional)", _t("The number of characters to return from the right side of string.")),
|
|
19655
19618
|
],
|
|
19656
|
-
returns: ["STRING"],
|
|
19657
19619
|
compute: function (text, ...args) {
|
|
19658
19620
|
const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
|
|
19659
19621
|
assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
|
|
@@ -19673,7 +19635,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19673
19635
|
arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
|
|
19674
19636
|
arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
|
|
19675
19637
|
],
|
|
19676
|
-
returns: ["NUMBER"],
|
|
19677
19638
|
compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
|
|
19678
19639
|
const _searchFor = toString(searchFor).toLowerCase();
|
|
19679
19640
|
const _textToSearch = toString(textToSearch).toLowerCase();
|
|
@@ -19700,7 +19661,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19700
19661
|
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
19662
|
consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.")),
|
|
19702
19663
|
],
|
|
19703
|
-
returns: ["RANGE<STRING>"],
|
|
19704
19664
|
compute: function (text, delimiter, splitByEach = { value: SPLIT_DEFAULT_SPLIT_BY_EACH }, removeEmptyText = { value: SPLIT_DEFAULT_REMOVE_EMPTY_TEXT }) {
|
|
19705
19665
|
const _text = toString(text);
|
|
19706
19666
|
const _delimiter = escapeRegExp(toString(delimiter));
|
|
@@ -19727,7 +19687,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19727
19687
|
arg("replace_with (string)", _t("The string that will replace search_for.")),
|
|
19728
19688
|
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
19689
|
],
|
|
19730
|
-
returns: ["NUMBER"],
|
|
19731
19690
|
compute: function (textToSearch, searchFor, replaceWith, occurrenceNumber) {
|
|
19732
19691
|
const _occurrenceNumber = toNumber(occurrenceNumber, this.locale);
|
|
19733
19692
|
assert(() => _occurrenceNumber >= 0, _t("The occurrenceNumber (%s) must be positive or null.", _occurrenceNumber.toString()));
|
|
@@ -19757,7 +19716,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19757
19716
|
arg("text1 (string, range<string>)", _t("Any text item. This could be a string, or an array of strings in a range.")),
|
|
19758
19717
|
arg("text2 (string, range<string>, repeating)", _t("Additional text item(s).")),
|
|
19759
19718
|
],
|
|
19760
|
-
returns: ["STRING"],
|
|
19761
19719
|
compute: function (delimiter, ignoreEmpty, ...textsOrArrays) {
|
|
19762
19720
|
const _delimiter = toString(delimiter);
|
|
19763
19721
|
const _ignoreEmpty = toBoolean(ignoreEmpty);
|
|
@@ -19774,7 +19732,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19774
19732
|
args: [
|
|
19775
19733
|
arg("text (string)", _t("The text or reference to a cell containing text to be trimmed.")),
|
|
19776
19734
|
],
|
|
19777
|
-
returns: ["STRING"],
|
|
19778
19735
|
compute: function (text) {
|
|
19779
19736
|
return trimContent(toString(text));
|
|
19780
19737
|
},
|
|
@@ -19786,7 +19743,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19786
19743
|
const UPPER = {
|
|
19787
19744
|
description: _t("Converts a specified string to uppercase."),
|
|
19788
19745
|
args: [arg("text (string)", _t("The string to convert to uppercase."))],
|
|
19789
|
-
returns: ["STRING"],
|
|
19790
19746
|
compute: function (text) {
|
|
19791
19747
|
return toString(text).toUpperCase();
|
|
19792
19748
|
},
|
|
@@ -19801,7 +19757,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19801
19757
|
arg("number (number)", _t("The number, date or time to format.")),
|
|
19802
19758
|
arg("format (string)", _t("The pattern by which to format the number, enclosed in quotation marks.")),
|
|
19803
19759
|
],
|
|
19804
|
-
returns: ["STRING"],
|
|
19805
19760
|
compute: function (number, format) {
|
|
19806
19761
|
const _number = toNumber(number, this.locale);
|
|
19807
19762
|
return formatValue(_number, { format: toString(format), locale: this.locale });
|
|
@@ -19842,7 +19797,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19842
19797
|
arg("url (string)", _t("The full URL of the link enclosed in quotation marks.")),
|
|
19843
19798
|
arg("link_label (string, optional)", _t("The text to display in the cell, enclosed in quotation marks.")),
|
|
19844
19799
|
],
|
|
19845
|
-
returns: ["STRING"],
|
|
19846
19800
|
compute: function (url, linkLabel) {
|
|
19847
19801
|
const processedUrl = toString(url).trim();
|
|
19848
19802
|
const processedLabel = toString(linkLabel) || processedUrl;
|
|
@@ -19901,6 +19855,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
19901
19855
|
}
|
|
19902
19856
|
args[i] = arg[0][0];
|
|
19903
19857
|
}
|
|
19858
|
+
if (!isMatrix(arg) && argDefinition.acceptMatrixOnly) {
|
|
19859
|
+
throw new BadExpressionError(_t("Function [[FUNCTION_NAME]] expects the parameter '%s' to be reference to a cell or range.", (i + 1).toString()));
|
|
19860
|
+
}
|
|
19904
19861
|
}
|
|
19905
19862
|
return descr.compute.apply(this, args);
|
|
19906
19863
|
}
|
|
@@ -21495,12 +21452,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21495
21452
|
// detect when an argument need to be evaluated as a meta argument
|
|
21496
21453
|
const isMeta = argTypes.includes("META");
|
|
21497
21454
|
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
21455
|
compiledArgs.push(compileAST(currentArg, isMeta, hasRange));
|
|
21505
21456
|
}
|
|
21506
21457
|
return compiledArgs;
|
|
@@ -21665,16 +21616,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21665
21616
|
function isRangeType(type) {
|
|
21666
21617
|
return type.startsWith("RANGE");
|
|
21667
21618
|
}
|
|
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
21619
|
|
|
21679
21620
|
const functions = functionRegistry.content;
|
|
21680
21621
|
function isExportableToExcel(tokens) {
|
|
@@ -21718,11 +21659,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21718
21659
|
function makeFieldProposal(field, granularity) {
|
|
21719
21660
|
const groupBy = granularity ? `${field.name}:${granularity}` : field.name;
|
|
21720
21661
|
const quotedGroupBy = `"${groupBy}"`;
|
|
21662
|
+
const fuzzySearchKey = field.string !== field.name
|
|
21663
|
+
? field.string + quotedGroupBy // search on translated name and on technical name
|
|
21664
|
+
: quotedGroupBy;
|
|
21721
21665
|
return {
|
|
21722
21666
|
text: quotedGroupBy,
|
|
21723
21667
|
description: field.string + (field.help ? ` (${field.help})` : ""),
|
|
21724
21668
|
htmlContent: [{ value: quotedGroupBy, color: tokenColors.STRING }],
|
|
21725
|
-
fuzzySearchKey
|
|
21669
|
+
fuzzySearchKey,
|
|
21726
21670
|
};
|
|
21727
21671
|
}
|
|
21728
21672
|
/**
|
|
@@ -21782,6 +21726,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21782
21726
|
return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS).length;
|
|
21783
21727
|
}
|
|
21784
21728
|
|
|
21729
|
+
/**
|
|
21730
|
+
* Registry to enable or disable the support of positional arguments
|
|
21731
|
+
* (with a leading #) in pivot functions
|
|
21732
|
+
* e.g. =PIVOT.VALUE(1,"probability","#stage",1)
|
|
21733
|
+
*/
|
|
21734
|
+
const supportedPivotPositionalFormulaRegistry = new Registry();
|
|
21735
|
+
supportedPivotPositionalFormulaRegistry.add("SPREADSHEET", false);
|
|
21736
|
+
|
|
21785
21737
|
autoCompleteProviders.add("pivot_ids", {
|
|
21786
21738
|
sequence: 50,
|
|
21787
21739
|
autoSelectFirstProposal: true,
|
|
@@ -21800,10 +21752,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21800
21752
|
return pivotIds
|
|
21801
21753
|
.map((pivotId) => {
|
|
21802
21754
|
const definition = this.getters.getPivotCoreDefinition(pivotId);
|
|
21803
|
-
if (functionContext.parent.toUpperCase() !== "PIVOT" &&
|
|
21804
|
-
!supportedPivotExplodedFormulaRegistry.get(definition.type)) {
|
|
21805
|
-
return undefined;
|
|
21806
|
-
}
|
|
21807
21755
|
const formulaId = this.getters.getPivotFormulaId(pivotId);
|
|
21808
21756
|
const str = `${formulaId}`;
|
|
21809
21757
|
return {
|
|
@@ -21831,15 +21779,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21831
21779
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21832
21780
|
return [];
|
|
21833
21781
|
}
|
|
21834
|
-
const
|
|
21835
|
-
|
|
21782
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21783
|
+
pivot.init();
|
|
21784
|
+
const fields = pivot.getFields();
|
|
21836
21785
|
if (!fields) {
|
|
21837
21786
|
return [];
|
|
21838
21787
|
}
|
|
21839
21788
|
const definition = this.getters.getPivotCoreDefinition(pivotId);
|
|
21840
|
-
if (!supportedPivotExplodedFormulaRegistry.get(definition.type)) {
|
|
21841
|
-
return [];
|
|
21842
|
-
}
|
|
21843
21789
|
return definition.measures
|
|
21844
21790
|
.map((measure) => {
|
|
21845
21791
|
if (measure.name === "__count") {
|
|
@@ -21875,16 +21821,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21875
21821
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21876
21822
|
return;
|
|
21877
21823
|
}
|
|
21878
|
-
const
|
|
21879
|
-
|
|
21824
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21825
|
+
pivot.init();
|
|
21826
|
+
const fields = pivot.getFields();
|
|
21880
21827
|
if (!fields) {
|
|
21881
21828
|
return;
|
|
21882
21829
|
}
|
|
21883
|
-
const {
|
|
21884
|
-
const { columns, rows } = dataSource.definition;
|
|
21885
|
-
if (!supportedPivotExplodedFormulaRegistry.get(type)) {
|
|
21886
|
-
return [];
|
|
21887
|
-
}
|
|
21830
|
+
const { columns, rows } = pivot.definition;
|
|
21888
21831
|
let args = functionContext.args;
|
|
21889
21832
|
if (functionContext?.parent.toUpperCase() === "PIVOT.VALUE") {
|
|
21890
21833
|
args = args.filter((ast, index) => index % 2 === 0); // keep only the field names
|
|
@@ -21921,6 +21864,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21921
21864
|
return field ? makeFieldProposal(field, granularity) : undefined;
|
|
21922
21865
|
})
|
|
21923
21866
|
.concat(groupBys.map((groupBy) => {
|
|
21867
|
+
if (!supportedPivotPositionalFormulaRegistry.get(pivot.type)) {
|
|
21868
|
+
return undefined;
|
|
21869
|
+
}
|
|
21924
21870
|
const fieldName = groupBy.split(":")[0];
|
|
21925
21871
|
const field = fields[fieldName];
|
|
21926
21872
|
if (!field) {
|
|
@@ -21969,12 +21915,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21969
21915
|
if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
|
|
21970
21916
|
return;
|
|
21971
21917
|
}
|
|
21972
|
-
const
|
|
21973
|
-
if (!
|
|
21974
|
-
return [];
|
|
21975
|
-
}
|
|
21976
|
-
const dataSource = this.getters.getPivot(pivotId);
|
|
21977
|
-
if (!dataSource.isValid()) {
|
|
21918
|
+
const pivot = this.getters.getPivot(pivotId);
|
|
21919
|
+
if (!pivot.isValid()) {
|
|
21978
21920
|
return;
|
|
21979
21921
|
}
|
|
21980
21922
|
const argPosition = functionContext.argPosition;
|
|
@@ -21982,7 +21924,46 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
21982
21924
|
if (!groupByField) {
|
|
21983
21925
|
return;
|
|
21984
21926
|
}
|
|
21985
|
-
|
|
21927
|
+
let dimension;
|
|
21928
|
+
try {
|
|
21929
|
+
dimension = pivot.definition.getDimension(groupByField);
|
|
21930
|
+
}
|
|
21931
|
+
catch (error) {
|
|
21932
|
+
return undefined;
|
|
21933
|
+
}
|
|
21934
|
+
if (dimension.granularity === "month_number") {
|
|
21935
|
+
return Object.values(MONTHS).map((monthDisplayName, index) => ({
|
|
21936
|
+
text: `${index + 1}`,
|
|
21937
|
+
fuzzySearchKey: monthDisplayName.toString(),
|
|
21938
|
+
description: monthDisplayName.toString(),
|
|
21939
|
+
htmlContent: [{ value: `${index + 1}`, color: tokenColors.NUMBER }],
|
|
21940
|
+
}));
|
|
21941
|
+
}
|
|
21942
|
+
else if (dimension.granularity === "quarter_number") {
|
|
21943
|
+
return [1, 2, 3, 4].map((quarter) => ({
|
|
21944
|
+
text: `${quarter}`,
|
|
21945
|
+
fuzzySearchKey: `${quarter}`,
|
|
21946
|
+
description: _t("Quarter %s", quarter),
|
|
21947
|
+
htmlContent: [{ value: `${quarter}`, color: tokenColors.NUMBER }],
|
|
21948
|
+
}));
|
|
21949
|
+
}
|
|
21950
|
+
else if (dimension.granularity === "day_of_month") {
|
|
21951
|
+
return range(1, 32).map((dayOfMonth) => ({
|
|
21952
|
+
text: `${dayOfMonth}`,
|
|
21953
|
+
fuzzySearchKey: `${dayOfMonth}`,
|
|
21954
|
+
description: "",
|
|
21955
|
+
htmlContent: [{ value: `${dayOfMonth}`, color: tokenColors.NUMBER }],
|
|
21956
|
+
}));
|
|
21957
|
+
}
|
|
21958
|
+
else if (dimension.granularity === "iso_week_number") {
|
|
21959
|
+
return range(0, 54).map((isoWeekNumber) => ({
|
|
21960
|
+
text: `${isoWeekNumber}`,
|
|
21961
|
+
fuzzySearchKey: `${isoWeekNumber}`,
|
|
21962
|
+
description: "",
|
|
21963
|
+
htmlContent: [{ value: `${isoWeekNumber}`, color: tokenColors.NUMBER }],
|
|
21964
|
+
}));
|
|
21965
|
+
}
|
|
21966
|
+
return pivot.getPossibleFieldValues(dimension).map(({ value, label }) => {
|
|
21986
21967
|
const isString = typeof value === "string";
|
|
21987
21968
|
const text = isString ? `"${value}"` : value.toString();
|
|
21988
21969
|
const color = isString ? tokenColors.STRING : tokenColors.NUMBER;
|
|
@@ -22089,7 +22070,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22089
22070
|
tooltip: content
|
|
22090
22071
|
? {
|
|
22091
22072
|
props: {
|
|
22092
|
-
content:
|
|
22073
|
+
content: data.cell
|
|
22074
|
+
? evaluateLiteral(data.cell, localeFormat).formattedValue
|
|
22075
|
+
: "",
|
|
22093
22076
|
},
|
|
22094
22077
|
}
|
|
22095
22078
|
: undefined,
|
|
@@ -22152,9 +22135,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22152
22135
|
if (x === cell) {
|
|
22153
22136
|
found = true;
|
|
22154
22137
|
}
|
|
22155
|
-
const cellValue = x
|
|
22156
|
-
? undefined
|
|
22157
|
-
: evaluateLiteral(x?.content, { locale: DEFAULT_LOCALE });
|
|
22138
|
+
const cellValue = x === undefined || x.isFormula ? undefined : evaluateLiteral(x, { locale: DEFAULT_LOCALE });
|
|
22158
22139
|
if (cellValue && filter(cellValue)) {
|
|
22159
22140
|
group.push(cellValue);
|
|
22160
22141
|
}
|
|
@@ -22202,7 +22183,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22202
22183
|
})
|
|
22203
22184
|
.add("increment_alphanumeric_value", {
|
|
22204
22185
|
condition: (cell) => !cell.isFormula &&
|
|
22205
|
-
evaluateLiteral(cell
|
|
22186
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text &&
|
|
22206
22187
|
alphaNumericValueRegExp.test(cell.content),
|
|
22207
22188
|
generateRule: (cell, cells) => {
|
|
22208
22189
|
const numberPostfix = parseInt(cell.content.match(numberPostfixRegExp)[0]);
|
|
@@ -22225,7 +22206,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22225
22206
|
})
|
|
22226
22207
|
.add("copy_text", {
|
|
22227
22208
|
condition: (cell) => !cell.isFormula &&
|
|
22228
|
-
evaluateLiteral(cell
|
|
22209
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text,
|
|
22229
22210
|
generateRule: () => {
|
|
22230
22211
|
return { type: "COPY_MODIFIER" };
|
|
22231
22212
|
},
|
|
@@ -22240,11 +22221,11 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
22240
22221
|
})
|
|
22241
22222
|
.add("increment_number", {
|
|
22242
22223
|
condition: (cell) => !cell.isFormula &&
|
|
22243
|
-
evaluateLiteral(cell
|
|
22224
|
+
evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.number,
|
|
22244
22225
|
generateRule: (cell, cells) => {
|
|
22245
22226
|
const group = getGroup(cell, cells, (evaluatedCell) => evaluatedCell.type === CellValueType.number).map((cell) => Number(cell.value));
|
|
22246
22227
|
const increment = calculateIncrementBasedOnGroup(group);
|
|
22247
|
-
const evaluation = evaluateLiteral(cell
|
|
22228
|
+
const evaluation = evaluateLiteral(cell, { locale: DEFAULT_LOCALE });
|
|
22248
22229
|
return {
|
|
22249
22230
|
type: "INCREMENT_MODIFIER",
|
|
22250
22231
|
increment,
|
|
@@ -25468,7 +25449,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25468
25449
|
if (!anchor)
|
|
25469
25450
|
return;
|
|
25470
25451
|
const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
|
|
25471
|
-
|
|
25452
|
+
let elDims = {
|
|
25472
25453
|
width: el.getBoundingClientRect().width,
|
|
25473
25454
|
height: el.getBoundingClientRect().height,
|
|
25474
25455
|
};
|
|
@@ -25476,7 +25457,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25476
25457
|
const popoverPositionHelper = this.props.positioning === "BottomLeft"
|
|
25477
25458
|
? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
|
|
25478
25459
|
: new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
|
|
25479
|
-
|
|
25460
|
+
el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
|
|
25461
|
+
el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
|
|
25462
|
+
// Re-compute the dimensions after setting the max-width and max-height
|
|
25463
|
+
elDims = {
|
|
25464
|
+
width: el.getBoundingClientRect().width,
|
|
25465
|
+
height: el.getBoundingClientRect().height,
|
|
25466
|
+
};
|
|
25467
|
+
let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
|
|
25480
25468
|
for (const property of Object.keys(style)) {
|
|
25481
25469
|
el.style[property] = style[property];
|
|
25482
25470
|
}
|
|
@@ -25539,8 +25527,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
25539
25527
|
const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
|
|
25540
25528
|
verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
|
|
25541
25529
|
const cssProperties = {
|
|
25542
|
-
"max-height": maxHeight + "px",
|
|
25543
|
-
"max-width": maxWidth + "px",
|
|
25544
25530
|
top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
|
|
25545
25531
|
this.spreadsheetOffset.y -
|
|
25546
25532
|
verticalOffset +
|
|
@@ -31354,10 +31340,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31354
31340
|
|
|
31355
31341
|
class AxisDesignEditor extends owl.Component {
|
|
31356
31342
|
static template = "o-spreadsheet-AxisDesignEditor";
|
|
31357
|
-
static components = {
|
|
31358
|
-
|
|
31359
|
-
ChartTitle,
|
|
31360
|
-
};
|
|
31343
|
+
static components = { Section, ChartTitle };
|
|
31344
|
+
static props = { figureId: String, definition: Object, updateChart: Function, axesList: Array };
|
|
31361
31345
|
state = owl.useState({ currentAxis: "x" });
|
|
31362
31346
|
get axisTitleStyle() {
|
|
31363
31347
|
const axisDesign = this.props.definition.axesDesign?.[this.state.currentAxis] ?? {};
|
|
@@ -31508,6 +31492,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
31508
31492
|
AxisDesignEditor,
|
|
31509
31493
|
RoundColorPicker,
|
|
31510
31494
|
};
|
|
31495
|
+
static props = {
|
|
31496
|
+
figureId: String,
|
|
31497
|
+
definition: Object,
|
|
31498
|
+
canUpdateChart: Function,
|
|
31499
|
+
updateChart: Function,
|
|
31500
|
+
};
|
|
31511
31501
|
state = owl.useState({ index: 0 });
|
|
31512
31502
|
get axesList() {
|
|
31513
31503
|
const { useLeftAxis, useRightAxis } = getDefinedAxis(this.props.definition);
|
|
@@ -33452,13 +33442,17 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
33452
33442
|
class: { type: String, optional: true },
|
|
33453
33443
|
};
|
|
33454
33444
|
static components = { Menu };
|
|
33445
|
+
menuId = new UuidGenerator().uuidv4();
|
|
33455
33446
|
selectRef = owl.useRef("select");
|
|
33456
33447
|
selectRect = useAbsoluteBoundingRect(this.selectRef);
|
|
33457
33448
|
state = owl.useState({
|
|
33458
33449
|
isMenuOpen: false,
|
|
33459
33450
|
});
|
|
33460
|
-
onClick() {
|
|
33461
|
-
this.
|
|
33451
|
+
onClick(ev) {
|
|
33452
|
+
if (ev.closedMenuId === this.menuId) {
|
|
33453
|
+
return;
|
|
33454
|
+
}
|
|
33455
|
+
this.state.isMenuOpen = !this.state.isMenuOpen;
|
|
33462
33456
|
}
|
|
33463
33457
|
onMenuClosed() {
|
|
33464
33458
|
this.state.isMenuOpen = false;
|
|
@@ -33466,7 +33460,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
33466
33460
|
get menuPosition() {
|
|
33467
33461
|
return {
|
|
33468
33462
|
x: this.selectRect.x,
|
|
33469
|
-
y: this.selectRect.y,
|
|
33463
|
+
y: this.selectRect.y + this.selectRect.height,
|
|
33470
33464
|
};
|
|
33471
33465
|
}
|
|
33472
33466
|
}
|
|
@@ -34406,9 +34400,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34406
34400
|
static props = {
|
|
34407
34401
|
onCloseSidePanel: Function,
|
|
34408
34402
|
};
|
|
34409
|
-
dataRange = "";
|
|
34410
34403
|
searchInput = owl.useRef("searchInput");
|
|
34411
34404
|
store;
|
|
34405
|
+
state;
|
|
34412
34406
|
get hasSearchResult() {
|
|
34413
34407
|
return this.store.selectedMatchIndex !== null;
|
|
34414
34408
|
}
|
|
@@ -34438,6 +34432,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34438
34432
|
}
|
|
34439
34433
|
setup() {
|
|
34440
34434
|
this.store = useLocalStore(FindAndReplaceStore);
|
|
34435
|
+
this.state = owl.useState({ dataRange: "" });
|
|
34441
34436
|
owl.onMounted(() => this.searchInput.el?.focus());
|
|
34442
34437
|
}
|
|
34443
34438
|
onFocusSearch() {
|
|
@@ -34474,13 +34469,13 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34474
34469
|
this.store.updateSearchOptions({ searchScope });
|
|
34475
34470
|
}
|
|
34476
34471
|
onSearchRangeChanged(ranges) {
|
|
34477
|
-
this.dataRange = ranges[0];
|
|
34472
|
+
this.state.dataRange = ranges[0];
|
|
34478
34473
|
}
|
|
34479
34474
|
updateDataRange() {
|
|
34480
|
-
if (!this.dataRange || this.searchOptions.searchScope !== "specificRange") {
|
|
34475
|
+
if (!this.state.dataRange || this.searchOptions.searchScope !== "specificRange") {
|
|
34481
34476
|
return;
|
|
34482
34477
|
}
|
|
34483
|
-
const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.dataRange);
|
|
34478
|
+
const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
|
|
34484
34479
|
this.store.updateSearchOptions({ specificRange });
|
|
34485
34480
|
}
|
|
34486
34481
|
}
|
|
@@ -34525,31 +34520,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34525
34520
|
}
|
|
34526
34521
|
}
|
|
34527
34522
|
|
|
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
34523
|
css /* scss */ `
|
|
34554
34524
|
.pivot-defer-update {
|
|
34555
34525
|
min-height: 35px;
|
|
@@ -34915,6 +34885,135 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
34915
34885
|
}
|
|
34916
34886
|
}
|
|
34917
34887
|
|
|
34888
|
+
css /* scss */ `
|
|
34889
|
+
.os-cog-wheel-menu-icon {
|
|
34890
|
+
cursor: pointer;
|
|
34891
|
+
}
|
|
34892
|
+
|
|
34893
|
+
.os-cog-wheel-menu {
|
|
34894
|
+
background: white;
|
|
34895
|
+
.btn-link {
|
|
34896
|
+
text-decoration: none;
|
|
34897
|
+
color: #017e84;
|
|
34898
|
+
font-weight: 500;
|
|
34899
|
+
&:hover {
|
|
34900
|
+
color: #01585c;
|
|
34901
|
+
}
|
|
34902
|
+
}
|
|
34903
|
+
}
|
|
34904
|
+
`;
|
|
34905
|
+
class CogWheelMenu extends owl.Component {
|
|
34906
|
+
static template = "o-spreadsheet-CogWheelMenu";
|
|
34907
|
+
static components = { Popover };
|
|
34908
|
+
static props = {
|
|
34909
|
+
items: Array,
|
|
34910
|
+
};
|
|
34911
|
+
buttonRef = owl.useRef("button");
|
|
34912
|
+
popover = owl.useState({ isOpen: false });
|
|
34913
|
+
setup() {
|
|
34914
|
+
owl.useExternalListener(window, "click", (ev) => {
|
|
34915
|
+
if (ev.target !== this.buttonRef.el) {
|
|
34916
|
+
this.popover.isOpen = false;
|
|
34917
|
+
}
|
|
34918
|
+
});
|
|
34919
|
+
}
|
|
34920
|
+
get popoverProps() {
|
|
34921
|
+
const { x, y, width, height } = this.buttonRef.el.getBoundingClientRect();
|
|
34922
|
+
return {
|
|
34923
|
+
anchorRect: { x, y, width, height },
|
|
34924
|
+
positioning: "BottomLeft",
|
|
34925
|
+
};
|
|
34926
|
+
}
|
|
34927
|
+
togglePopover() {
|
|
34928
|
+
this.popover.isOpen = !this.popover.isOpen;
|
|
34929
|
+
}
|
|
34930
|
+
}
|
|
34931
|
+
|
|
34932
|
+
/** @odoo-module */
|
|
34933
|
+
class EditableName extends owl.Component {
|
|
34934
|
+
static template = "o-spreadsheet-EditableName";
|
|
34935
|
+
static props = {
|
|
34936
|
+
name: String,
|
|
34937
|
+
displayName: String,
|
|
34938
|
+
onChanged: Function,
|
|
34939
|
+
};
|
|
34940
|
+
state;
|
|
34941
|
+
setup() {
|
|
34942
|
+
this.state = owl.useState({
|
|
34943
|
+
isEditing: false,
|
|
34944
|
+
name: "",
|
|
34945
|
+
});
|
|
34946
|
+
}
|
|
34947
|
+
rename() {
|
|
34948
|
+
this.state.isEditing = true;
|
|
34949
|
+
this.state.name = this.props.name;
|
|
34950
|
+
}
|
|
34951
|
+
save() {
|
|
34952
|
+
this.props.onChanged(this.state.name.trim());
|
|
34953
|
+
this.state.isEditing = false;
|
|
34954
|
+
}
|
|
34955
|
+
}
|
|
34956
|
+
|
|
34957
|
+
class PivotTitleSection extends owl.Component {
|
|
34958
|
+
static template = "o-spreadsheet-PivotTitleSection";
|
|
34959
|
+
static components = { CogWheelMenu, Section, EditableName };
|
|
34960
|
+
static props = {
|
|
34961
|
+
pivotId: String,
|
|
34962
|
+
};
|
|
34963
|
+
get cogWheelMenuItems() {
|
|
34964
|
+
return [
|
|
34965
|
+
{
|
|
34966
|
+
name: "Duplicate",
|
|
34967
|
+
icon: "fa-copy",
|
|
34968
|
+
onClick: () => this.duplicatePivot(),
|
|
34969
|
+
},
|
|
34970
|
+
{
|
|
34971
|
+
name: "Delete",
|
|
34972
|
+
icon: "fa-trash",
|
|
34973
|
+
onClick: () => this.delete(),
|
|
34974
|
+
},
|
|
34975
|
+
];
|
|
34976
|
+
}
|
|
34977
|
+
get name() {
|
|
34978
|
+
return this.env.model.getters.getPivotName(this.props.pivotId);
|
|
34979
|
+
}
|
|
34980
|
+
get displayName() {
|
|
34981
|
+
return this.env.model.getters.getPivotDisplayName(this.props.pivotId);
|
|
34982
|
+
}
|
|
34983
|
+
duplicatePivot() {
|
|
34984
|
+
const newPivotId = this.env.model.uuidGenerator.uuidv4();
|
|
34985
|
+
const result = this.env.model.dispatch("DUPLICATE_PIVOT", {
|
|
34986
|
+
pivotId: this.props.pivotId,
|
|
34987
|
+
newPivotId,
|
|
34988
|
+
});
|
|
34989
|
+
const text = result.isSuccessful ? _t("Pivot duplicated.") : _t("Pivot duplication failed");
|
|
34990
|
+
const type = result.isSuccessful ? "success" : "danger";
|
|
34991
|
+
this.env.notifyUser({
|
|
34992
|
+
text,
|
|
34993
|
+
sticky: false,
|
|
34994
|
+
type,
|
|
34995
|
+
});
|
|
34996
|
+
if (result.isSuccessful) {
|
|
34997
|
+
this.env.openSidePanel("PivotSidePanel", { pivotId: newPivotId });
|
|
34998
|
+
}
|
|
34999
|
+
}
|
|
35000
|
+
delete() {
|
|
35001
|
+
this.env.askConfirmation(_t("Are you sure you want to delete this pivot?"), () => {
|
|
35002
|
+
this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
|
|
35003
|
+
});
|
|
35004
|
+
}
|
|
35005
|
+
onNameChanged(name) {
|
|
35006
|
+
const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
|
|
35007
|
+
this.env.model.dispatch("UPDATE_PIVOT", {
|
|
35008
|
+
pivotId: this.props.pivotId,
|
|
35009
|
+
pivot: {
|
|
35010
|
+
...pivot,
|
|
35011
|
+
name,
|
|
35012
|
+
},
|
|
35013
|
+
});
|
|
35014
|
+
}
|
|
35015
|
+
}
|
|
35016
|
+
|
|
34918
35017
|
/**
|
|
34919
35018
|
* Represent a pivot runtime definition. A pivot runtime definition is a pivot
|
|
34920
35019
|
* definition that has been enriched to include the display name of its attributes
|
|
@@ -35219,7 +35318,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35219
35318
|
}
|
|
35220
35319
|
const row = rows[index];
|
|
35221
35320
|
const rowName = row.nameWithGranularity;
|
|
35222
|
-
const groups =
|
|
35321
|
+
const groups = groupPivotDataEntriesBy(dataEntries, row);
|
|
35223
35322
|
const orderedKeys = orderDataEntriesKeys(groups, row);
|
|
35224
35323
|
const pivotTableRows = [];
|
|
35225
35324
|
const _fields = fields.concat(rowName);
|
|
@@ -35249,7 +35348,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35249
35348
|
}
|
|
35250
35349
|
const column = columns[index];
|
|
35251
35350
|
const colName = columns[index].nameWithGranularity;
|
|
35252
|
-
const groups =
|
|
35351
|
+
const groups = groupPivotDataEntriesBy(dataEntries, column);
|
|
35253
35352
|
const orderedKeys = orderDataEntriesKeys(groups, columns[index]);
|
|
35254
35353
|
return orderedKeys.map((value) => {
|
|
35255
35354
|
return {
|
|
@@ -35347,7 +35446,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35347
35446
|
/**
|
|
35348
35447
|
* Group the dataEntries based on the given dimension
|
|
35349
35448
|
*/
|
|
35350
|
-
function
|
|
35449
|
+
function groupPivotDataEntriesBy(dataEntries, dimension) {
|
|
35351
35450
|
return Object.groupBy(dataEntries, keySelector(dimension));
|
|
35352
35451
|
}
|
|
35353
35452
|
/**
|
|
@@ -35397,7 +35496,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35397
35496
|
number = Math.floor(date.getMonth() / 3) + 1;
|
|
35398
35497
|
break;
|
|
35399
35498
|
case "month_number":
|
|
35400
|
-
number = date.getMonth();
|
|
35499
|
+
number = date.getMonth() + 1;
|
|
35401
35500
|
break;
|
|
35402
35501
|
case "iso_week_number":
|
|
35403
35502
|
number = date.getIsoWeek();
|
|
@@ -35409,7 +35508,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35409
35508
|
number = Math.floor(toNumber(value, locale));
|
|
35410
35509
|
break;
|
|
35411
35510
|
}
|
|
35412
|
-
MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = number;
|
|
35511
|
+
MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = toNormalizedPivotValue(dimension, number);
|
|
35413
35512
|
}
|
|
35414
35513
|
return MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`];
|
|
35415
35514
|
}
|
|
@@ -35555,7 +35654,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35555
35654
|
return this._definition;
|
|
35556
35655
|
}
|
|
35557
35656
|
isValid() {
|
|
35558
|
-
if (this.invalidRangeError || !this.
|
|
35657
|
+
if (this.invalidRangeError || !this.definition) {
|
|
35559
35658
|
return false;
|
|
35560
35659
|
}
|
|
35561
35660
|
for (const measure of this.definition.measures) {
|
|
@@ -35612,25 +35711,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35612
35711
|
const dimension = this.getDimension(lastNode.field);
|
|
35613
35712
|
const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
|
|
35614
35713
|
const finalCell = cells[0]?.[dimension.nameWithGranularity];
|
|
35714
|
+
if (dimension.type === "date") {
|
|
35715
|
+
const adapter = pivotTimeAdapter(dimension.granularity);
|
|
35716
|
+
return {
|
|
35717
|
+
value: adapter.toCellValue(toNormalizedPivotValue(dimension, lastNode.value)),
|
|
35718
|
+
format: adapter.getFormat(this.getters.getLocale()),
|
|
35719
|
+
};
|
|
35720
|
+
}
|
|
35615
35721
|
if (!finalCell) {
|
|
35616
35722
|
return { value: "" };
|
|
35617
35723
|
}
|
|
35618
35724
|
if (finalCell.value === null) {
|
|
35619
35725
|
return { value: _t("(Undefined)") };
|
|
35620
35726
|
}
|
|
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
35727
|
return {
|
|
35635
35728
|
value: finalCell.value,
|
|
35636
35729
|
format: finalCell.format,
|
|
@@ -35655,9 +35748,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35655
35748
|
format: operator.format(values[0]),
|
|
35656
35749
|
};
|
|
35657
35750
|
}
|
|
35658
|
-
getPossibleFieldValues(
|
|
35659
|
-
|
|
35660
|
-
|
|
35751
|
+
getPossibleFieldValues(dimension) {
|
|
35752
|
+
const values = [];
|
|
35753
|
+
for (const value in groupPivotDataEntriesBy(this.dataEntries, dimension)) {
|
|
35754
|
+
values.push({ value, label: "" });
|
|
35755
|
+
}
|
|
35756
|
+
return values;
|
|
35661
35757
|
}
|
|
35662
35758
|
getTableStructure() {
|
|
35663
35759
|
if (!this.isValid()) {
|
|
@@ -35677,7 +35773,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35677
35773
|
filterDataEntriesFromDomainNode(dataEntries, domain) {
|
|
35678
35774
|
const { field, value } = domain;
|
|
35679
35775
|
const dimension = this.getDimension(field);
|
|
35680
|
-
return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` ===
|
|
35776
|
+
return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` ===
|
|
35777
|
+
`${toNormalizedPivotValue(dimension, value)}`);
|
|
35681
35778
|
}
|
|
35682
35779
|
getDimension(nameWithGranularity) {
|
|
35683
35780
|
return this.definition.getDimension(nameWithGranularity);
|
|
@@ -35813,15 +35910,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35813
35910
|
|
|
35814
35911
|
class PivotSidePanelStore extends SpreadsheetStore {
|
|
35815
35912
|
pivotId;
|
|
35816
|
-
mutators = [
|
|
35817
|
-
|
|
35818
|
-
"deferUpdates",
|
|
35819
|
-
"applyUpdate",
|
|
35820
|
-
"discardPendingUpdate",
|
|
35821
|
-
"renamePivot",
|
|
35822
|
-
"update",
|
|
35823
|
-
];
|
|
35824
|
-
updatesAreDeferred = true;
|
|
35913
|
+
mutators = ["reset", "deferUpdates", "applyUpdate", "discardPendingUpdate", "update"];
|
|
35914
|
+
updatesAreDeferred = false;
|
|
35825
35915
|
draft = null;
|
|
35826
35916
|
constructor(get, pivotId) {
|
|
35827
35917
|
super(get);
|
|
@@ -35938,16 +36028,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
35938
36028
|
discardPendingUpdate() {
|
|
35939
36029
|
this.draft = null;
|
|
35940
36030
|
}
|
|
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
36031
|
update(definitionUpdate) {
|
|
35952
36032
|
const coreDefinition = this.getters.getPivotCoreDefinition(this.pivotId);
|
|
35953
36033
|
const definition = { ...coreDefinition, ...this.draft, ...definitionUpdate };
|
|
@@ -36030,9 +36110,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36030
36110
|
PivotLayoutConfigurator,
|
|
36031
36111
|
Section,
|
|
36032
36112
|
SelectionInput,
|
|
36033
|
-
EditableName,
|
|
36034
36113
|
Checkbox,
|
|
36035
36114
|
PivotDeferUpdate,
|
|
36115
|
+
PivotTitleSection,
|
|
36036
36116
|
};
|
|
36037
36117
|
store;
|
|
36038
36118
|
state;
|
|
@@ -36061,12 +36141,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36061
36141
|
get pivot() {
|
|
36062
36142
|
return this.store.pivot;
|
|
36063
36143
|
}
|
|
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
36144
|
get definition() {
|
|
36071
36145
|
return this.store.definition;
|
|
36072
36146
|
}
|
|
@@ -36090,35 +36164,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36090
36164
|
this.store.applyUpdate();
|
|
36091
36165
|
}
|
|
36092
36166
|
}
|
|
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
36167
|
onDimensionsUpdated(definition) {
|
|
36114
36168
|
this.store.update(definition);
|
|
36115
36169
|
}
|
|
36116
|
-
back() {
|
|
36117
|
-
this.env.openSidePanel("PivotSidePanel", {});
|
|
36118
|
-
}
|
|
36119
|
-
delete() {
|
|
36120
|
-
this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
|
|
36121
|
-
}
|
|
36122
36170
|
}
|
|
36123
36171
|
|
|
36124
36172
|
const pivotSidePanelRegistry = new Registry();
|
|
@@ -36126,44 +36174,17 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36126
36174
|
editor: PivotSpreadsheetSidePanel,
|
|
36127
36175
|
});
|
|
36128
36176
|
|
|
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
36177
|
class PivotSidePanel extends owl.Component {
|
|
36153
36178
|
static template = "o-spreadsheet-PivotSidePanel";
|
|
36154
36179
|
static props = {
|
|
36155
|
-
pivotId:
|
|
36180
|
+
pivotId: String,
|
|
36156
36181
|
onCloseSidePanel: Function,
|
|
36157
36182
|
};
|
|
36158
36183
|
static components = {
|
|
36159
36184
|
PivotLayoutConfigurator,
|
|
36160
36185
|
Section,
|
|
36161
|
-
PivotListItem,
|
|
36162
36186
|
};
|
|
36163
36187
|
get sidePanelEditor() {
|
|
36164
|
-
if (!this.props.pivotId) {
|
|
36165
|
-
throw new Error("pivotId is required to call this function.");
|
|
36166
|
-
}
|
|
36167
36188
|
const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
|
|
36168
36189
|
if (!pivot) {
|
|
36169
36190
|
throw new Error("pivotId does not correspond to a pivot.");
|
|
@@ -36180,6 +36201,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
36180
36201
|
class RemoveDuplicatesPanel extends owl.Component {
|
|
36181
36202
|
static template = "o-spreadsheet-RemoveDuplicatesPanel";
|
|
36182
36203
|
static components = { ValidationMessages, Section, Checkbox };
|
|
36204
|
+
static props = { onCloseSidePanel: Function };
|
|
36183
36205
|
state = owl.useState({
|
|
36184
36206
|
hasHeader: false,
|
|
36185
36207
|
columns: {},
|
|
@@ -37322,21 +37344,15 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
37322
37344
|
});
|
|
37323
37345
|
sidePanelRegistry.add("PivotSidePanel", {
|
|
37324
37346
|
title: (env, props) => {
|
|
37325
|
-
|
|
37326
|
-
return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
|
|
37327
|
-
}
|
|
37328
|
-
return _t("List of Pivots");
|
|
37347
|
+
return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
|
|
37329
37348
|
},
|
|
37330
37349
|
Body: PivotSidePanel,
|
|
37331
|
-
computeState: (getters,
|
|
37332
|
-
|
|
37333
|
-
|
|
37334
|
-
|
|
37335
|
-
|
|
37336
|
-
|
|
37337
|
-
pivotId = undefined;
|
|
37338
|
-
}
|
|
37339
|
-
return { isOpen: true, props: { pivotId }, key: `pivot_key_${pivotId}` };
|
|
37350
|
+
computeState: (getters, props) => {
|
|
37351
|
+
return {
|
|
37352
|
+
isOpen: getters.isExistingPivot(props.pivotId),
|
|
37353
|
+
props,
|
|
37354
|
+
key: `pivot_key_${props.pivotId}`,
|
|
37355
|
+
};
|
|
37340
37356
|
},
|
|
37341
37357
|
});
|
|
37342
37358
|
|
|
@@ -41594,133 +41610,6 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
41594
41610
|
}
|
|
41595
41611
|
}
|
|
41596
41612
|
|
|
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
41613
|
/**
|
|
41725
41614
|
* Represent a raw XML string
|
|
41726
41615
|
*/
|
|
@@ -46919,9 +46808,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
46919
46808
|
}
|
|
46920
46809
|
createLiteralCell(id, content, format, style) {
|
|
46921
46810
|
const locale = this.getters.getLocale();
|
|
46922
|
-
|
|
46811
|
+
const parsedValue = parseLiteral(content, locale);
|
|
46812
|
+
format =
|
|
46813
|
+
format ||
|
|
46814
|
+
(typeof parsedValue === "number"
|
|
46815
|
+
? detectDateFormat(content, locale) || detectNumberFormat(content)
|
|
46816
|
+
: undefined);
|
|
46923
46817
|
if (format !== PLAIN_TEXT_FORMAT && !isEvaluationError(content)) {
|
|
46924
|
-
content = toString(
|
|
46818
|
+
content = toString(parsedValue);
|
|
46925
46819
|
}
|
|
46926
46820
|
return {
|
|
46927
46821
|
id,
|
|
@@ -46929,6 +46823,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
46929
46823
|
style,
|
|
46930
46824
|
format,
|
|
46931
46825
|
isFormula: false,
|
|
46826
|
+
parsedValue,
|
|
46932
46827
|
};
|
|
46933
46828
|
}
|
|
46934
46829
|
createFormulaCell(id, content, format, style, sheetId) {
|
|
@@ -51671,6 +51566,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
51671
51566
|
get({ sheetId, col, row }) {
|
|
51672
51567
|
return this.map[sheetId]?.[col]?.[row];
|
|
51673
51568
|
}
|
|
51569
|
+
getSheet(sheetId) {
|
|
51570
|
+
return this.map[sheetId];
|
|
51571
|
+
}
|
|
51674
51572
|
has({ sheetId, col, row }) {
|
|
51675
51573
|
return this.map[sheetId]?.[col]?.[row] !== undefined;
|
|
51676
51574
|
}
|
|
@@ -51689,6 +51587,19 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
51689
51587
|
}
|
|
51690
51588
|
return keys;
|
|
51691
51589
|
}
|
|
51590
|
+
keysForSheet(sheetId) {
|
|
51591
|
+
const map = this.map[sheetId];
|
|
51592
|
+
if (!map) {
|
|
51593
|
+
return [];
|
|
51594
|
+
}
|
|
51595
|
+
const keys = [];
|
|
51596
|
+
for (const col in map) {
|
|
51597
|
+
for (const row in map[col]) {
|
|
51598
|
+
keys.push({ sheetId, col: parseInt(col), row: parseInt(row) });
|
|
51599
|
+
}
|
|
51600
|
+
}
|
|
51601
|
+
return keys;
|
|
51602
|
+
}
|
|
51692
51603
|
}
|
|
51693
51604
|
|
|
51694
51605
|
function quickselect(arr, k, left, right, compare) {
|
|
@@ -52767,6 +52678,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52767
52678
|
getEvaluatedPositions() {
|
|
52768
52679
|
return this.evaluatedCells.keys();
|
|
52769
52680
|
}
|
|
52681
|
+
getEvaluatedPositionsInSheet(sheetId) {
|
|
52682
|
+
return this.evaluatedCells.keysForSheet(sheetId);
|
|
52683
|
+
}
|
|
52770
52684
|
getArrayFormulaSpreadingOn(position) {
|
|
52771
52685
|
if (!this.spreadingRelations.hasArrayFormulaResult(position)) {
|
|
52772
52686
|
return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
|
|
@@ -52775,6 +52689,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52775
52689
|
return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
|
|
52776
52690
|
}
|
|
52777
52691
|
updateDependencies(position) {
|
|
52692
|
+
// removing dependencies is slow because it requires
|
|
52693
|
+
// to traverse the entire r-tree.
|
|
52694
|
+
// The data structure is optimized for searches the other way around
|
|
52778
52695
|
this.formulaDependencies().removeAllDependencies(position);
|
|
52779
52696
|
const dependencies = this.getDirectDependencies(position);
|
|
52780
52697
|
this.formulaDependencies().addDependencies(position, dependencies);
|
|
@@ -52940,7 +52857,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
52940
52857
|
this.cellsBeingComputed.add(cellId);
|
|
52941
52858
|
return cell.isFormula
|
|
52942
52859
|
? this.computeFormulaCell(position.sheetId, cell)
|
|
52943
|
-
: evaluateLiteral(cell
|
|
52860
|
+
: evaluateLiteral(cell, localeFormat);
|
|
52944
52861
|
}
|
|
52945
52862
|
catch (e) {
|
|
52946
52863
|
e.value = e?.value || CellErrorType.GenericError;
|
|
@@ -53210,6 +53127,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
53210
53127
|
"getEvaluatedCell",
|
|
53211
53128
|
"getEvaluatedCells",
|
|
53212
53129
|
"getEvaluatedCellsInZone",
|
|
53130
|
+
"getEvaluatedCellsPositions",
|
|
53213
53131
|
"getSpreadZone",
|
|
53214
53132
|
"getArrayFormulaSpreadingOn",
|
|
53215
53133
|
"isEmpty",
|
|
@@ -53301,13 +53219,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
53301
53219
|
return this.evaluator.getEvaluatedCell(position);
|
|
53302
53220
|
}
|
|
53303
53221
|
getEvaluatedCells(sheetId) {
|
|
53304
|
-
|
|
53305
|
-
|
|
53306
|
-
|
|
53307
|
-
|
|
53308
|
-
|
|
53309
|
-
|
|
53310
|
-
return record;
|
|
53222
|
+
return this.evaluator
|
|
53223
|
+
.getEvaluatedPositionsInSheet(sheetId)
|
|
53224
|
+
.map((position) => this.getEvaluatedCell(position));
|
|
53225
|
+
}
|
|
53226
|
+
getEvaluatedCellsPositions(sheetId) {
|
|
53227
|
+
return this.evaluator.getEvaluatedPositionsInSheet(sheetId);
|
|
53311
53228
|
}
|
|
53312
53229
|
getEvaluatedCellsInZone(sheetId, zone) {
|
|
53313
53230
|
return positions(zone).map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId, col, row }));
|
|
@@ -55975,7 +55892,10 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
55975
55892
|
/**
|
|
55976
55893
|
* Notify the server that the user client left the collaborative session
|
|
55977
55894
|
*/
|
|
55978
|
-
leave() {
|
|
55895
|
+
leave(data) {
|
|
55896
|
+
if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
|
|
55897
|
+
this.snapshot(data);
|
|
55898
|
+
}
|
|
55979
55899
|
delete this.clients[this.clientId];
|
|
55980
55900
|
this.transportService.leave(this.clientId);
|
|
55981
55901
|
this.transportService.sendMessage({
|
|
@@ -56389,7 +56309,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
56389
56309
|
bottom: rowIndex,
|
|
56390
56310
|
}));
|
|
56391
56311
|
const handler = new CellClipboardHandler(this.getters, this.dispatch);
|
|
56392
|
-
const data = handler.copy(getClipboardDataPositions(rowsToKeep));
|
|
56312
|
+
const data = handler.copy(getClipboardDataPositions(sheetId, rowsToKeep));
|
|
56393
56313
|
if (!data) {
|
|
56394
56314
|
return;
|
|
56395
56315
|
}
|
|
@@ -56402,7 +56322,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
56402
56322
|
right: zone.left,
|
|
56403
56323
|
bottom: zone.top,
|
|
56404
56324
|
};
|
|
56405
|
-
handler.paste({ zones: [zonePasted] }, data, { isCutOperation: false });
|
|
56325
|
+
handler.paste({ zones: [zonePasted], sheetId }, data, { isCutOperation: false });
|
|
56406
56326
|
const remainingZone = {
|
|
56407
56327
|
left: zone.left,
|
|
56408
56328
|
top: zone.top - (hasHeader ? 1 : 0),
|
|
@@ -58276,12 +58196,14 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
58276
58196
|
}
|
|
58277
58197
|
let zone = undefined;
|
|
58278
58198
|
let selectedZones = [];
|
|
58199
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
58279
58200
|
let target = {
|
|
58201
|
+
sheetId,
|
|
58280
58202
|
zones,
|
|
58281
58203
|
};
|
|
58282
58204
|
const handlers = this.selectClipboardHandlers(copiedData);
|
|
58283
58205
|
for (const handler of handlers) {
|
|
58284
|
-
const currentTarget = handler.getPasteTarget(zones, copiedData, options);
|
|
58206
|
+
const currentTarget = handler.getPasteTarget(sheetId, zones, copiedData, options);
|
|
58285
58207
|
if (currentTarget.figureId) {
|
|
58286
58208
|
target.figureId = currentTarget.figureId;
|
|
58287
58209
|
}
|
|
@@ -58450,11 +58372,12 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
58450
58372
|
return { cut: [cut], paste: [paste] };
|
|
58451
58373
|
}
|
|
58452
58374
|
getClipboardData(zones) {
|
|
58375
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
58453
58376
|
const selectedFigureId = this.getters.getSelectedFigureId();
|
|
58454
58377
|
if (selectedFigureId) {
|
|
58455
|
-
return { figureId: selectedFigureId };
|
|
58378
|
+
return { figureId: selectedFigureId, sheetId };
|
|
58456
58379
|
}
|
|
58457
|
-
return getClipboardDataPositions(zones);
|
|
58380
|
+
return getClipboardDataPositions(sheetId, zones);
|
|
58458
58381
|
}
|
|
58459
58382
|
// ---------------------------------------------------------------------------
|
|
58460
58383
|
// Grid rendering
|
|
@@ -59120,8 +59043,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
59120
59043
|
bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
59121
59044
|
},
|
|
59122
59045
|
];
|
|
59046
|
+
const sheetId = this.getActiveSheetId();
|
|
59123
59047
|
const handler = new CellClipboardHandler(this.getters, this.dispatch);
|
|
59124
|
-
const data = handler.copy(getClipboardDataPositions(target));
|
|
59048
|
+
const data = handler.copy(getClipboardDataPositions(sheetId, target));
|
|
59125
59049
|
if (!data) {
|
|
59126
59050
|
return;
|
|
59127
59051
|
}
|
|
@@ -59134,7 +59058,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
59134
59058
|
bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
|
|
59135
59059
|
},
|
|
59136
59060
|
];
|
|
59137
|
-
handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
|
|
59061
|
+
handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
|
|
59138
59062
|
const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
|
|
59139
59063
|
let currentIndex = cmd.base;
|
|
59140
59064
|
for (const element of toRemove) {
|
|
@@ -66498,7 +66422,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66498
66422
|
this.session.join(this.config.client);
|
|
66499
66423
|
}
|
|
66500
66424
|
leaveSession() {
|
|
66501
|
-
this.session.leave();
|
|
66425
|
+
this.session.leave(this.exportData());
|
|
66502
66426
|
}
|
|
66503
66427
|
setupUiPlugin(Plugin) {
|
|
66504
66428
|
const plugin = new Plugin(this.uiPluginConfig);
|
|
@@ -66905,7 +66829,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66905
66829
|
pivotRegistry,
|
|
66906
66830
|
pivotTimeAdapterRegistry,
|
|
66907
66831
|
pivotSidePanelRegistry,
|
|
66908
|
-
|
|
66832
|
+
pivotNormalizationValueRegistry,
|
|
66833
|
+
supportedPivotPositionalFormulaRegistry,
|
|
66909
66834
|
};
|
|
66910
66835
|
const helpers = {
|
|
66911
66836
|
arg,
|
|
@@ -66914,6 +66839,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
66914
66839
|
toJsDate,
|
|
66915
66840
|
toNumber,
|
|
66916
66841
|
toString,
|
|
66842
|
+
toNormalizedPivotValue,
|
|
66917
66843
|
toXC,
|
|
66918
66844
|
toZone,
|
|
66919
66845
|
toUnboundedZone,
|
|
@@ -67009,6 +66935,8 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
67009
66935
|
PivotLayoutConfigurator,
|
|
67010
66936
|
EditableName,
|
|
67011
66937
|
PivotDeferUpdate,
|
|
66938
|
+
PivotTitleSection,
|
|
66939
|
+
CogWheelMenu,
|
|
67012
66940
|
};
|
|
67013
66941
|
const hooks = {
|
|
67014
66942
|
useDragAndDropListItems,
|
|
@@ -67092,9 +67020,9 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
67092
67020
|
exports.tokenize = tokenize;
|
|
67093
67021
|
|
|
67094
67022
|
|
|
67095
|
-
__info__.version = "17.4.0-alpha.
|
|
67096
|
-
__info__.date = "2024-06-
|
|
67097
|
-
__info__.hash = "
|
|
67023
|
+
__info__.version = "17.4.0-alpha.4";
|
|
67024
|
+
__info__.date = "2024-06-12T14:00:22.046Z";
|
|
67025
|
+
__info__.hash = "cefb0e4";
|
|
67098
67026
|
|
|
67099
67027
|
|
|
67100
67028
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|