@adaptabletools/adaptable 12.2.0-canary.1 → 12.2.2
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/bundle.cjs.js +75 -75
- package/package.json +1 -1
- package/publishTimestamp.d.ts +1 -1
- package/publishTimestamp.js +1 -1
- package/src/AdaptableOptions/AdaptableQLOptions.d.ts +11 -2
- package/src/Utilities/Services/QueryLanguageService.js +1 -1
- package/src/agGrid/Adaptable.d.ts +1 -1
- package/src/agGrid/Adaptable.js +3 -24
- package/src/agGrid/weightedAverage.d.ts +1 -0
- package/src/agGrid/weightedAverage.js +28 -45
- package/src/metamodel/adaptable.metamodel.d.ts +12 -0
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/types.d.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.2",
|
|
4
4
|
"description": "Powerful data-agnostic HTML5 datagrid add-on that sits on top of an underlying grid component and provides all the rich functionality that advanced users expect from their DataGrids and Data Tables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
package/publishTimestamp.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: 1661928464536;
|
|
2
2
|
export default _default;
|
package/publishTimestamp.js
CHANGED
|
@@ -114,7 +114,7 @@ export interface ExpressionOptions {
|
|
|
114
114
|
/**
|
|
115
115
|
* Custom query variables allow values to be attached to variables so that a single value can easily be expressed multiple times within a query, or quickly changed to affect the results of a query. Variables are evaluated synchronously with each expression evaluation.
|
|
116
116
|
*/
|
|
117
|
-
|
|
117
|
+
customQueryVariables?: Record<string, string | number | boolean | Date | ((context: CustomQueryVariableContext) => string | number | boolean | Date)>;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Module specific Expression Functions
|
|
@@ -127,7 +127,7 @@ export interface ModuleExpressionFunctions {
|
|
|
127
127
|
aggregatedScalarFunctions?: ExpressionFunctionMap;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
|
-
* Context passed when evaluating `ExpressionOptions.
|
|
130
|
+
* Context passed when evaluating `ExpressionOptions.customQueryVariables`
|
|
131
131
|
*/
|
|
132
132
|
export interface CustomQueryVariableContext extends BaseContext {
|
|
133
133
|
/**
|
|
@@ -139,7 +139,16 @@ export interface CustomQueryVariableContext extends BaseContext {
|
|
|
139
139
|
* Context passed when evaluating `AdaptableQLOptions.evaluateExpressionExternally()`
|
|
140
140
|
*/
|
|
141
141
|
export interface EvaluateExpressionExternallyContext extends BaseContext {
|
|
142
|
+
/**
|
|
143
|
+
* Module where the Expression is being evaluated
|
|
144
|
+
*/
|
|
142
145
|
module: AdaptableQLModule;
|
|
146
|
+
/**
|
|
147
|
+
* Expression to evlauate
|
|
148
|
+
*/
|
|
143
149
|
expression?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Columns contained in the Expression
|
|
152
|
+
*/
|
|
144
153
|
referencedColumns?: AdaptableColumn[];
|
|
145
154
|
}
|
|
@@ -312,7 +312,7 @@ class QueryLanguageService {
|
|
|
312
312
|
adaptableApi: this.adaptableApi,
|
|
313
313
|
args,
|
|
314
314
|
};
|
|
315
|
-
const customQueryVariableDefinition = (_c = (_b = (_a = this.adaptableApi.internalApi.getAdaptableOptions().adaptableQLOptions) === null || _a === void 0 ? void 0 : _a.expressionOptions) === null || _b === void 0 ? void 0 : _b.
|
|
315
|
+
const customQueryVariableDefinition = (_c = (_b = (_a = this.adaptableApi.internalApi.getAdaptableOptions().adaptableQLOptions) === null || _a === void 0 ? void 0 : _a.expressionOptions) === null || _b === void 0 ? void 0 : _b.customQueryVariables) === null || _c === void 0 ? void 0 : _c[functionName];
|
|
316
316
|
return typeof customQueryVariableDefinition === 'function'
|
|
317
317
|
? customQueryVariableDefinition(context)
|
|
318
318
|
: customQueryVariableDefinition;
|
|
@@ -226,7 +226,7 @@ export declare class Adaptable implements IAdaptable {
|
|
|
226
226
|
private mapColumnDefs;
|
|
227
227
|
private getColDefsForSpecialColumns;
|
|
228
228
|
getColDefsForFreeTextColumns(): ColDef[];
|
|
229
|
-
setupColumnValueGetter({ col
|
|
229
|
+
setupColumnValueGetter({ col }: ColumnSetupInfo): void;
|
|
230
230
|
setupColumnAggFunc({ col }: ColumnSetupInfo): void;
|
|
231
231
|
private getColDefsForRowEditColumns;
|
|
232
232
|
getColDefsForActionColumns(): ColDef[];
|
package/src/agGrid/Adaptable.js
CHANGED
|
@@ -2197,31 +2197,10 @@ class Adaptable {
|
|
|
2197
2197
|
return newColDef;
|
|
2198
2198
|
});
|
|
2199
2199
|
}
|
|
2200
|
-
setupColumnValueGetter({ col
|
|
2200
|
+
setupColumnValueGetter({ col }) {
|
|
2201
|
+
// need this here if we want plugins to intercept
|
|
2201
2202
|
this.setColDefProperty(col, 'valueGetter', (userValue) => {
|
|
2202
|
-
return
|
|
2203
|
-
const columnId = abColumn.columnId;
|
|
2204
|
-
let evaluatedUserValue = userValue;
|
|
2205
|
-
if (typeof userValue === 'function') {
|
|
2206
|
-
evaluatedUserValue = userValue(params);
|
|
2207
|
-
}
|
|
2208
|
-
const defaultValue = evaluatedUserValue
|
|
2209
|
-
? evaluatedUserValue
|
|
2210
|
-
: (params === null || params === void 0 ? void 0 : params.data)
|
|
2211
|
-
? params.data[columnId]
|
|
2212
|
-
: undefined;
|
|
2213
|
-
const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
|
|
2214
|
-
if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage' && !params.node.group) {
|
|
2215
|
-
const weightedColumnId = adaptableAggFunc.weightedColumnId;
|
|
2216
|
-
return {
|
|
2217
|
-
[columnId]: defaultValue,
|
|
2218
|
-
[weightedColumnId]: params.data[weightedColumnId],
|
|
2219
|
-
toString: () => (defaultValue ? `${defaultValue}` : ''),
|
|
2220
|
-
valueOf: () => defaultValue,
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
return defaultValue;
|
|
2224
|
-
};
|
|
2203
|
+
return userValue;
|
|
2225
2204
|
});
|
|
2226
2205
|
}
|
|
2227
2206
|
setupColumnAggFunc({ col }) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IAggFuncParams } from '@ag-grid-community/all-modules';
|
|
2
2
|
import { CellSummaryOperationContext } from '../types';
|
|
3
|
+
export declare const getNumericValue: (input: unknown) => number | null;
|
|
3
4
|
export declare const weightedAverage: (params: IAggFuncParams, columnId: string, weightColumnId: string) => {
|
|
4
5
|
[x: string]: number | (() => number | "");
|
|
5
6
|
toString: () => number | "";
|
|
@@ -1,64 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cellSummaryWeightedAverage = exports.weightedAverage = void 0;
|
|
3
|
+
exports.cellSummaryWeightedAverage = exports.weightedAverage = exports.getNumericValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const StringExtensions_1 = tslib_1.__importDefault(require("../Utilities/Extensions/StringExtensions"));
|
|
6
5
|
const FormatHelper_1 = tslib_1.__importDefault(require("../Utilities/Helpers/FormatHelper"));
|
|
6
|
+
const toNumber_1 = tslib_1.__importDefault(require("lodash/toNumber"));
|
|
7
|
+
const getNumericValue = (input) => {
|
|
8
|
+
if (typeof input === 'number') {
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
const numericValue = toNumber_1.default(input);
|
|
12
|
+
return isNaN(numericValue) ? null : numericValue;
|
|
13
|
+
};
|
|
14
|
+
exports.getNumericValue = getNumericValue;
|
|
7
15
|
const weightedAverage = (params, columnId, weightColumnId) => {
|
|
16
|
+
const { api: gridApi, rowNode: groupRowNode } = params;
|
|
8
17
|
let weightedColumnValueSum = 0;
|
|
9
18
|
let columnValueSum = 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const columnValue = StringExtensions_1.default.IsNotNullOrEmpty(rawColumnValue)
|
|
20
|
-
? Number(value[columnId])
|
|
21
|
-
: null;
|
|
22
|
-
const rawWeightedColumnValue = value[weightColumnId];
|
|
23
|
-
if (typeof rawWeightedColumnValue === 'object') {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const weightedColumnValue = StringExtensions_1.default.IsNotNullOrEmpty(rawWeightedColumnValue)
|
|
27
|
-
? Number(value[weightColumnId])
|
|
28
|
-
: null;
|
|
29
|
-
if (params.rowNode.leafGroup) {
|
|
30
|
-
if (weightedColumnValue !== null) {
|
|
31
|
-
weightedColumnValueSum += weightedColumnValue;
|
|
32
|
-
}
|
|
33
|
-
if (columnValue !== null && weightedColumnValue !== null) {
|
|
34
|
-
columnValueSum += weightedColumnValue * columnValue;
|
|
35
|
-
}
|
|
19
|
+
// TODO AFL: improve performance by using the intermediary aggregated values (for nested groups)
|
|
20
|
+
groupRowNode.allLeafChildren.forEach((rowNode) => {
|
|
21
|
+
// when editing values might be converted to strings
|
|
22
|
+
const rawColumnValue = gridApi.getValue(columnId, rowNode);
|
|
23
|
+
const columnValue = exports.getNumericValue(rawColumnValue);
|
|
24
|
+
const rawWeightedColumnValue = gridApi.getValue(weightColumnId, rowNode);
|
|
25
|
+
const weightedColumnValue = exports.getNumericValue(rawWeightedColumnValue);
|
|
26
|
+
if (weightedColumnValue !== null) {
|
|
27
|
+
weightedColumnValueSum += weightedColumnValue;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
weightedColumnValueSum += weightedColumnValue;
|
|
40
|
-
}
|
|
41
|
-
if (columnValue !== null) {
|
|
42
|
-
columnValueSum += columnValue;
|
|
43
|
-
}
|
|
29
|
+
if (columnValue !== null) {
|
|
30
|
+
columnValueSum += columnValue * weightedColumnValue;
|
|
44
31
|
}
|
|
45
32
|
});
|
|
46
33
|
return {
|
|
47
34
|
toString: () => {
|
|
48
|
-
const
|
|
35
|
+
const result = columnValueSum / weightedColumnValueSum;
|
|
49
36
|
// 0 / 0 = NaN
|
|
50
|
-
if (isNaN(
|
|
37
|
+
if (isNaN(result)) {
|
|
51
38
|
return '';
|
|
52
39
|
}
|
|
53
|
-
return
|
|
40
|
+
return result;
|
|
54
41
|
},
|
|
55
42
|
valueOf: () => {
|
|
56
|
-
const
|
|
43
|
+
const result = columnValueSum / weightedColumnValueSum;
|
|
57
44
|
// 0 / 0 = NaN
|
|
58
|
-
if (isNaN(
|
|
45
|
+
if (isNaN(result)) {
|
|
59
46
|
return 0;
|
|
60
47
|
}
|
|
61
|
-
return
|
|
48
|
+
return result;
|
|
62
49
|
},
|
|
63
50
|
[columnId]: columnValueSum,
|
|
64
51
|
[weightColumnId]: weightedColumnValueSum,
|
|
@@ -69,10 +56,6 @@ const cellSummaryWeightedAverage = ({ numericColumns, selectedCellInfo, adaptabl
|
|
|
69
56
|
if ((numericColumns === null || numericColumns === void 0 ? void 0 : numericColumns.length) != 1) {
|
|
70
57
|
return '';
|
|
71
58
|
}
|
|
72
|
-
const currentSummaryOperation = adaptableApi.cellSummaryApi.getCurrentCellSummaryOperation();
|
|
73
|
-
if (typeof currentSummaryOperation !== 'string' || currentSummaryOperation !== 'Weighted Avg') {
|
|
74
|
-
return '';
|
|
75
|
-
}
|
|
76
59
|
const columnId = numericColumns[0];
|
|
77
60
|
const currentLayout = adaptableApi.layoutApi.getCurrentLayout();
|
|
78
61
|
const selectedColumnAgg = currentLayout.AggregationColumns[columnId];
|
|
@@ -1967,6 +1967,18 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
1967
1967
|
kind: string;
|
|
1968
1968
|
description: string;
|
|
1969
1969
|
};
|
|
1970
|
+
CustomQueryVariableContext: {
|
|
1971
|
+
name: string;
|
|
1972
|
+
kind: string;
|
|
1973
|
+
description: string;
|
|
1974
|
+
properties: {
|
|
1975
|
+
name: string;
|
|
1976
|
+
kind: string;
|
|
1977
|
+
description: string;
|
|
1978
|
+
uiLabel: string;
|
|
1979
|
+
isOptional: boolean;
|
|
1980
|
+
}[];
|
|
1981
|
+
};
|
|
1970
1982
|
CustomRenderContext: {
|
|
1971
1983
|
name: string;
|
|
1972
1984
|
kind: string;
|