@adaptabletools/adaptable 12.2.0 → 12.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "12.2.0",
3
+ "version": "12.2.1",
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",
@@ -1,2 +1,2 @@
1
- declare const _default: 1661766017905;
1
+ declare const _default: 1661859148986;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1661766017905;
3
+ exports.default = 1661859148986;
@@ -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, abColumn }: ColumnSetupInfo): void;
229
+ setupColumnValueGetter({ col }: ColumnSetupInfo): void;
230
230
  setupColumnAggFunc({ col }: ColumnSetupInfo): void;
231
231
  private getColDefsForRowEditColumns;
232
232
  getColDefsForActionColumns(): ColDef[];
@@ -2197,31 +2197,10 @@ class Adaptable {
2197
2197
  return newColDef;
2198
2198
  });
2199
2199
  }
2200
- setupColumnValueGetter({ col, abColumn }) {
2200
+ setupColumnValueGetter({ col }) {
2201
+ // need this here if we want plugins to intercept
2201
2202
  this.setColDefProperty(col, 'valueGetter', (userValue) => {
2202
- return (params) => {
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
- params.values.forEach((value) => {
11
- if (!value) {
12
- return;
13
- }
14
- // when editing values become string
15
- const rawColumnValue = value[columnId];
16
- if (typeof rawColumnValue === 'object') {
17
- return;
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
- else {
38
- if (weightedColumnValue !== null) {
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 rez = columnValueSum / weightedColumnValueSum;
35
+ const result = columnValueSum / weightedColumnValueSum;
49
36
  // 0 / 0 = NaN
50
- if (isNaN(rez)) {
37
+ if (isNaN(result)) {
51
38
  return '';
52
39
  }
53
- return rez;
40
+ return result;
54
41
  },
55
42
  valueOf: () => {
56
- const rez = columnValueSum / weightedColumnValueSum;
43
+ const result = columnValueSum / weightedColumnValueSum;
57
44
  // 0 / 0 = NaN
58
- if (isNaN(rez)) {
45
+ if (isNaN(result)) {
59
46
  return 0;
60
47
  }
61
- return rez;
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];
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "12.2.0";
1
+ declare const _default: "12.2.1";
2
2
  export default _default;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '12.2.0'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version
3
+ exports.default = '12.2.1'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version