@adaptabletools/adaptable 12.1.6 → 12.1.8-canary.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.
Files changed (203) hide show
  1. package/base.css +11 -49
  2. package/bundle.cjs.js +106 -106
  3. package/index.css +13 -60
  4. package/package.json +1 -1
  5. package/publishTimestamp.d.ts +1 -1
  6. package/publishTimestamp.js +1 -1
  7. package/src/AdaptableInterfaces/IAdaptable.d.ts +2 -0
  8. package/src/AdaptableOptions/ColumnOptions.d.ts +2 -4
  9. package/src/AdaptableOptions/FilterOptions.d.ts +12 -0
  10. package/src/AdaptableOptions/FinancePluginOptions.d.ts +22 -1
  11. package/src/AdaptableOptions/StateOptions.d.ts +25 -12
  12. package/src/Api/ColumnApi.d.ts +5 -0
  13. package/src/Api/ExportApi.d.ts +5 -0
  14. package/src/Api/FilterApi.d.ts +23 -0
  15. package/src/Api/FlashingCellApi.d.ts +8 -0
  16. package/src/Api/GridApi.d.ts +1 -0
  17. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  18. package/src/Api/Implementation/ColumnApiImpl.js +5 -1
  19. package/src/Api/Implementation/ExportApiImpl.d.ts +3 -1
  20. package/src/Api/Implementation/ExportApiImpl.js +19 -3
  21. package/src/Api/Implementation/FilterApiImpl.d.ts +5 -0
  22. package/src/Api/Implementation/FilterApiImpl.js +35 -3
  23. package/src/Api/Implementation/FlashingCellApiImpl.d.ts +1 -0
  24. package/src/Api/Implementation/FlashingCellApiImpl.js +4 -0
  25. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  26. package/src/Api/Implementation/InternalApiImpl.d.ts +0 -1
  27. package/src/Api/Implementation/InternalApiImpl.js +0 -3
  28. package/src/Api/Implementation/PredicateApiImpl.js +4 -0
  29. package/src/Api/Implementation/QueryLanguageApiImpl.js +9 -1
  30. package/src/Api/InternalApi.d.ts +0 -1
  31. package/src/Api/SystemStatusApi.d.ts +1 -1
  32. package/src/Api/ToolPanelApi.d.ts +1 -1
  33. package/src/PredefinedConfig/CalculatedColumnState.d.ts +2 -2
  34. package/src/PredefinedConfig/Common/AdaptablePredicate.js +30 -10
  35. package/src/PredefinedConfig/Common/AdaptableQuery.js +1 -1
  36. package/src/PredefinedConfig/Common/AggregationColumns.d.ts +6 -0
  37. package/src/PredefinedConfig/Common/AggregationColumns.js +4 -0
  38. package/src/PredefinedConfig/Common/ColumnFilter.d.ts +2 -2
  39. package/src/PredefinedConfig/Common/Enums.d.ts +0 -15
  40. package/src/PredefinedConfig/Common/Enums.js +1 -18
  41. package/src/PredefinedConfig/Common/SpecialColumnSettings.d.ts +6 -6
  42. package/src/PredefinedConfig/ExportState.d.ts +12 -4
  43. package/src/PredefinedConfig/LayoutState.d.ts +2 -1
  44. package/src/PredefinedConfig/PopupState.d.ts +1 -2
  45. package/src/Redux/ActionsReducers/AlertRedux.d.ts +1 -1
  46. package/src/Redux/ActionsReducers/AlertRedux.js +1 -1
  47. package/src/Redux/ActionsReducers/ConditionalStyleRedux.d.ts +1 -1
  48. package/src/Redux/ActionsReducers/ConditionalStyleRedux.js +1 -1
  49. package/src/Redux/ActionsReducers/CustomSortRedux.d.ts +1 -1
  50. package/src/Redux/ActionsReducers/CustomSortRedux.js +1 -1
  51. package/src/Redux/ActionsReducers/FlashingCellRedux.d.ts +1 -1
  52. package/src/Redux/ActionsReducers/FlashingCellRedux.js +1 -1
  53. package/src/Redux/ActionsReducers/FormatColumnRedux.d.ts +1 -1
  54. package/src/Redux/ActionsReducers/FormatColumnRedux.js +1 -1
  55. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +28 -0
  56. package/src/Redux/ActionsReducers/LayoutRedux.js +80 -2
  57. package/src/Redux/ActionsReducers/PlusMinusRedux.d.ts +1 -1
  58. package/src/Redux/ActionsReducers/PlusMinusRedux.js +1 -1
  59. package/src/Redux/ActionsReducers/PopupRedux.d.ts +0 -2
  60. package/src/Redux/ActionsReducers/PopupRedux.js +1 -28
  61. package/src/Redux/ActionsReducers/ScheduleRedux.d.ts +5 -5
  62. package/src/Redux/ActionsReducers/ScheduleRedux.js +5 -5
  63. package/src/Redux/ActionsReducers/ShortcutRedux.d.ts +1 -1
  64. package/src/Redux/ActionsReducers/ShortcutRedux.js +1 -1
  65. package/src/Redux/ActionsReducers/SystemRedux.d.ts +1 -2
  66. package/src/Redux/ActionsReducers/SystemRedux.js +1 -2
  67. package/src/Redux/Store/AdaptableStore.js +20 -6
  68. package/src/Strategy/AlertModule.d.ts +1 -0
  69. package/src/Strategy/AlertModule.js +20 -0
  70. package/src/Strategy/CalculatedColumnModule.js +2 -2
  71. package/src/Strategy/ExportModule.d.ts +0 -1
  72. package/src/Strategy/ExportModule.js +0 -16
  73. package/src/Strategy/FilterModule.js +6 -0
  74. package/src/Strategy/FlashingCellModule.js +2 -2
  75. package/src/Strategy/Interface/IModule.d.ts +4 -0
  76. package/src/Strategy/LayoutModule.js +20 -20
  77. package/src/Strategy/Utilities/FormatColumn/getFormatColumnStyleViewItems.js +16 -1
  78. package/src/Strategy/Utilities/Layout/getLayoutFilterViewItems.js +15 -11
  79. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +1 -0
  80. package/src/Utilities/Constants/DocumentationLinkConstants.js +2 -1
  81. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +2 -0
  82. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.d.ts +12 -2
  83. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.js +30 -66
  84. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +22 -6
  85. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +423 -220
  86. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +7 -1
  87. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +23 -7
  88. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +0 -1
  89. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +6 -54
  90. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +17 -5
  91. package/src/Utilities/Helpers/CalendarHelper.js +10 -7
  92. package/src/Utilities/Helpers/DateHelper.d.ts +0 -26
  93. package/src/Utilities/Helpers/DateHelper.js +2 -32
  94. package/src/Utilities/Interface/MessagePopups.d.ts +0 -4
  95. package/src/Utilities/ObjectFactory.d.ts +6 -4
  96. package/src/Utilities/ObjectFactory.js +30 -17
  97. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +25 -0
  98. package/src/Utilities/Services/AggregatedScalarLiveValue.js +103 -0
  99. package/src/Utilities/Services/AlertService.d.ts +0 -1
  100. package/src/Utilities/Services/AlertService.js +5 -17
  101. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +4 -4
  102. package/src/Utilities/Services/CalculatedColumnExpressionService.js +29 -154
  103. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +2 -2
  104. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +6 -3
  105. package/src/Utilities/Services/QueryLanguageService.d.ts +6 -3
  106. package/src/Utilities/Services/QueryLanguageService.js +23 -6
  107. package/src/Utilities/Services/ReportService.js +47 -46
  108. package/src/View/AdaptableView.js +1 -2
  109. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingsTags.d.ts +2 -0
  110. package/src/View/CalculatedColumn/Utilities/{getCalculatedColumnSettingTags.js → getCalculatedColumnSettingsTags.js} +5 -3
  111. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.d.ts +10 -0
  112. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.js +80 -0
  113. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +21 -15
  114. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.d.ts +1 -2
  115. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +10 -53
  116. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +14 -3
  117. package/src/View/Components/AdaptableDateInput/index.js +1 -1
  118. package/src/View/Components/AdaptableObjectList/AdaptableObjectCompactList.js +42 -6
  119. package/src/View/Components/AdaptableObjectList/AdaptableObjectList.js +1 -1
  120. package/src/View/Components/EntityRulesEditor/index.js +26 -5
  121. package/src/View/Components/FilterForm/FilterForm.js +8 -4
  122. package/src/View/Components/FilterForm/ListBoxFilterForm.js +1 -0
  123. package/src/View/Components/FilterForm/QuickFilterForm.js +10 -6
  124. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.d.ts +9 -0
  125. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.js +28 -0
  126. package/src/View/Components/PermittedValuesSelector/index.d.ts +1 -0
  127. package/src/View/Components/PermittedValuesSelector/index.js +5 -0
  128. package/src/View/Components/Popups/AdaptablePopup/Navigation.js +2 -2
  129. package/src/View/Components/Popups/AdaptableToaster.js +2 -7
  130. package/src/View/Components/Popups/WindowPopups/windowFactory.d.ts +0 -1
  131. package/src/View/Components/Popups/WindowPopups/windowFactory.js +1 -4
  132. package/src/View/Export/ExportViewPanel.d.ts +1 -2
  133. package/src/View/Export/ExportViewPanel.js +2 -6
  134. package/src/View/Export/Wizard/ReportColumnTypeWizard.d.ts +1 -2
  135. package/src/View/Export/Wizard/ReportColumnTypeWizard.js +11 -12
  136. package/src/View/Export/Wizard/ReportRowTypeWizard.d.ts +1 -2
  137. package/src/View/Export/Wizard/ReportRowTypeWizard.js +12 -13
  138. package/src/View/Export/Wizard/ReportSettingsWizard.js +1 -2
  139. package/src/View/Filter/FilterViewPanel.js +20 -4
  140. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  141. package/src/View/FreeTextColumn/FreeTextColumnSummary.js +1 -2
  142. package/src/View/FreeTextColumn/Wizard/FreeTextColumnSettingsWizardSection.d.ts +1 -1
  143. package/src/View/FreeTextColumn/Wizard/FreeTextColumnWizard.js +1 -1
  144. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.d.ts +0 -0
  145. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.js +0 -0
  146. package/src/View/Layout/Wizard/LayoutWizard.js +1 -0
  147. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +1 -0
  148. package/src/View/Layout/Wizard/sections/AggregationsSection.js +69 -8
  149. package/src/View/Layout/Wizard/sections/ColumnsSection.js +1 -1
  150. package/src/View/Query/QueryViewPanel.js +1 -1
  151. package/src/agGrid/Adaptable.d.ts +11 -3
  152. package/src/agGrid/Adaptable.js +224 -150
  153. package/src/agGrid/agGridHelper.d.ts +1 -0
  154. package/src/agGrid/agGridHelper.js +5 -3
  155. package/src/agGrid/agGridMenuHelper.d.ts +1 -0
  156. package/src/agGrid/agGridMenuHelper.js +4 -2
  157. package/src/agGrid/weightedAverage.d.ts +6 -0
  158. package/src/agGrid/weightedAverage.js +66 -0
  159. package/src/bundle-dependencies/bundles/react-toastify/index.js +1 -1
  160. package/src/components/ExpressionEditor/BaseEditorInput.d.ts +1 -0
  161. package/src/components/ExpressionEditor/BaseEditorInput.js +2 -3
  162. package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
  163. package/src/components/ExpressionEditor/EditorInput.js +24 -4
  164. package/src/components/ExpressionEditor/{EditorInputReactive.d.ts → EditorInputWithWhereClause.d.ts} +3 -3
  165. package/src/components/ExpressionEditor/{EditorInputReactive.js → EditorInputWithWhereClause.js} +6 -5
  166. package/src/components/ExpressionEditor/editorButtonsAggregatedBoolean.d.ts +2 -0
  167. package/src/components/ExpressionEditor/{editorButtonsReactive.js → editorButtonsAggregatedBoolean.js} +22 -37
  168. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +5 -10
  169. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.d.ts +2 -0
  170. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.js +50 -0
  171. package/src/components/ExpressionEditor/editorButtonsObservable.d.ts +2 -0
  172. package/src/components/ExpressionEditor/editorButtonsObservable.js +40 -0
  173. package/src/components/ExpressionEditor/index.d.ts +1 -1
  174. package/src/components/ExpressionEditor/index.js +26 -5
  175. package/src/metamodel/adaptable.metamodel.d.ts +55 -1
  176. package/src/metamodel/adaptable.metamodel.js +1 -1
  177. package/src/types.d.ts +3 -3
  178. package/version.d.ts +1 -1
  179. package/version.js +1 -1
  180. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingTags.d.ts +0 -2
  181. package/src/View/Layout/LayoutEditorStandalonePopup.d.ts +0 -3
  182. package/src/View/Layout/LayoutEditorStandalonePopup.js +0 -78
  183. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.d.ts +0 -27
  184. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.js +0 -86
  185. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.d.ts +0 -16
  186. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.js +0 -89
  187. package/src/View/Layout/Wizard/LayoutEditor/PivotList.d.ts +0 -15
  188. package/src/View/Layout/Wizard/LayoutEditor/PivotList.js +0 -70
  189. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.d.ts +0 -15
  190. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.js +0 -70
  191. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.d.ts +0 -7
  192. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.js +0 -11
  193. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.d.ts +0 -6
  194. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.js +0 -26
  195. package/src/View/Layout/Wizard/LayoutEditor/index.d.ts +0 -9
  196. package/src/View/Layout/Wizard/LayoutEditor/index.js +0 -367
  197. package/src/View/Layout/Wizard/LayoutEditor/reducer.d.ts +0 -28
  198. package/src/View/Layout/Wizard/LayoutEditor/reducer.js +0 -46
  199. package/src/View/Layout/Wizard/LayoutEditor/utils.d.ts +0 -10
  200. package/src/View/Layout/Wizard/LayoutEditor/utils.js +0 -14
  201. package/src/View/Layout/Wizard/LayoutEditorWizard.d.ts +0 -30
  202. package/src/View/Layout/Wizard/LayoutEditorWizard.js +0 -132
  203. package/src/components/ExpressionEditor/editorButtonsReactive.d.ts +0 -2
@@ -62,6 +62,8 @@ const StatusBarState_1 = require("../PredefinedConfig/StatusBarState");
62
62
  const createAgStatusPanelComponent_1 = require("./createAgStatusPanelComponent");
63
63
  const AdaptableStatusBar_1 = require("../View/StatusBar/AdaptableStatusBar");
64
64
  const RowEditService_1 = require("../Utilities/Services/RowEditService");
65
+ const weightedAverage_1 = require("./weightedAverage");
66
+ const AggregationColumns_1 = require("../PredefinedConfig/Common/AggregationColumns");
65
67
  const tinycolor = require('tinycolor2');
66
68
  all_modules_1.ModuleRegistry.registerModules(all_modules_1.AllCommunityModules);
67
69
  const GROUP_PATH_SEPARATOR = '/';
@@ -365,6 +367,7 @@ class Adaptable {
365
367
  this.isInitialised = false;
366
368
  this.useRowNodeLookUp = false; // we will set later in instantiate if possible to be true
367
369
  this.forPlugins((plugin) => plugin.afterInitOptions(this, this.adaptableOptions));
370
+ this.registerAdaptableAggFuncs();
368
371
  // get the api ready
369
372
  this.api = new AdaptableApiImpl_1.AdaptableApiImpl(this);
370
373
  this.forPlugins((plugin) => plugin.afterInitApi(this, this.api));
@@ -375,10 +378,13 @@ class Adaptable {
375
378
  this.agGridMenuHelper = new agGridMenuHelper_1.agGridMenuHelper(this, this.gridOptions);
376
379
  // Build the default group sort comparator - will get custom sort values (but not functions) in real time
377
380
  // TODO: if a custom 'aggFunc' property is defined (see setupColumnAggFunc()), it won't be evaluated
378
- if (!this.getInitialGroupOrderComparator(this.gridOptions) &&
379
- this.adaptableOptions.columnOptions.autoOrderGroupedColumns) {
380
- this.gridOptions.initialGroupOrderComparator =
381
- this.agGridHelper.runAdaptableGroupComparerFunction();
381
+ if (this.adaptableOptions.columnOptions.autoOrderGroupedColumns) {
382
+ this.setGridOptionsProperty('initialGroupOrderComparator', (userPropertyValue) => {
383
+ if (userPropertyValue) {
384
+ return userPropertyValue;
385
+ }
386
+ return this.agGridHelper.runAdaptableGroupComparerFunction();
387
+ });
382
388
  }
383
389
  // we prefer the grid to be NOT instantiated so that we can do it
384
390
  // perhaps in future we will force instantiation only?
@@ -571,15 +577,6 @@ class Adaptable {
571
577
  }
572
578
  if ((_a = this.adaptableOptions.generalOptions) === null || _a === void 0 ? void 0 : _a.hideEmptyGroupRows) {
573
579
  LoggingHelper_1.ConsoleLogWarning(`DEPRECATED: 'GeneralOptions.hideEmptyGroupRows' is deprecated and will no longer be evaluated!`);
574
- // disabled due to showstopper starting with AG Grid v26
575
- // the internal implementation of AG Grids GroupCellRenderer has changed A LOT!
576
- // this.gridOptions.components = this.gridOptions.components || {};
577
- //
578
- // this.gridOptions.autoGroupColumnDef = this.gridOptions.autoGroupColumnDef || {};
579
- // if (!this.gridOptions.autoGroupColumnDef.cellRenderer) {
580
- // this.gridOptions.autoGroupColumnDef.cellRenderer = '__adaptableGroupCellRenderer';
581
- // this.gridOptions.components.__adaptableGroupCellRenderer = AdaptableGroupCellRenderer;
582
- // }
583
580
  }
584
581
  const adaptableSideBarDef = this.createAdaptableSideBarDef();
585
582
  if (!!adaptableSideBarDef) {
@@ -587,12 +584,9 @@ class Adaptable {
587
584
  this.gridOptions.components.AdaptableToolPanel = AdaptableToolPanel_1.getAdaptableToolPanelAgGridComponent(this);
588
585
  }
589
586
  if (this.agGridHelper.isSideBarDefObject(adaptableSideBarDef)) {
590
- if (this.gridOptions.api) {
591
- this.gridOptions.api.setSideBar(adaptableSideBarDef);
592
- }
593
- else {
594
- this.gridOptions.sideBar = adaptableSideBarDef;
595
- }
587
+ this.setGridOptionsProperty('sideBar', () => {
588
+ return adaptableSideBarDef;
589
+ });
596
590
  this.hasAdaptableToolPanel = true;
597
591
  }
598
592
  this.createStatusBars();
@@ -720,24 +714,25 @@ class Adaptable {
720
714
  }
721
715
  }
722
716
  createStatusBars() {
723
- var _a, _b;
724
- const statusBarOptions = Object.assign({}, this.gridOptions.statusBar);
725
717
  const adaptableStatusPanelKeys = [];
726
- const statusPanels = (_b = ((_a = statusBarOptions === null || statusBarOptions === void 0 ? void 0 : statusBarOptions.statusPanels) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.map((statusPanel) => {
727
- if (statusPanel.statusPanel === StatusBarState_1.ADAPTABLE_STATUS_PANEL) {
728
- adaptableStatusPanelKeys.push(statusPanel.key);
729
- const context = {
730
- Key: statusPanel.key,
731
- };
732
- return Object.assign(Object.assign({}, statusPanel), { statusPanel: createAgStatusPanelComponent_1.createAgStatusPanelComponent(AdaptableStatusBar_1.AdaptableStatusBar, this, context) });
733
- }
734
- return statusPanel;
718
+ this.setGridOptionsProperty('statusBar', (originalStatusBar) => {
719
+ var _a, _b;
720
+ const statusPanels = (_b = ((_a = originalStatusBar === null || originalStatusBar === void 0 ? void 0 : originalStatusBar.statusPanels) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.map((statusPanel) => {
721
+ if (statusPanel.statusPanel === StatusBarState_1.ADAPTABLE_STATUS_PANEL) {
722
+ adaptableStatusPanelKeys.push(statusPanel.key);
723
+ const context = {
724
+ Key: statusPanel.key,
725
+ };
726
+ return Object.assign(Object.assign({}, statusPanel), { statusPanel: createAgStatusPanelComponent_1.createAgStatusPanelComponent(AdaptableStatusBar_1.AdaptableStatusBar, this, context) });
727
+ }
728
+ return statusPanel;
729
+ });
730
+ return Object.assign(Object.assign({}, originalStatusBar), { statusPanels });
735
731
  });
736
- statusBarOptions.statusPanels = statusPanels;
737
- this.gridOptions.statusBar = statusBarOptions;
738
732
  const statusBarModule = this.ModuleService.getModuleById(ModuleConstants.StatusBarModuleId);
739
733
  this.api.eventApi.on('AdaptableReady', () => {
740
- const adaptableStatusPanels = statusPanels.filter((statusPanel) => adaptableStatusPanelKeys.includes(statusPanel.key));
734
+ var _a, _b;
735
+ const adaptableStatusPanels = (_b = (_a = this.gridOptions.statusBar) === null || _a === void 0 ? void 0 : _a.statusPanels) === null || _b === void 0 ? void 0 : _b.filter((statusPanel) => adaptableStatusPanelKeys.includes(statusPanel.key));
741
736
  // need to add only the adaptable panels
742
737
  statusBarModule.syncStateWithOptions(adaptableStatusPanels);
743
738
  });
@@ -1331,15 +1326,25 @@ class Adaptable {
1331
1326
  newColState.aggFunc = null;
1332
1327
  if (aggregationFunctionsColumnsMap[colId] != null) {
1333
1328
  const colDef = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.getColumnDef(colId);
1334
- newColState.aggFunc =
1335
- aggregationFunctionsColumnsMap[colId] === true
1336
- ? // if we have true, it means - take the default aggFunc from colDef
1337
- // NOTE: colState gives us the current aggFunc, which can be null,
1338
- // while the colDef gives us the initially configured aggFunc for that column
1339
- (_e = (_d = (_c = colState.aggFunc) !== null && _c !== void 0 ? _c : colDef === null || colDef === void 0 ? void 0 : colDef.aggFunc) !== null && _d !== void 0 ? _d :
1340
- // @ts-ignore available only wth ag-Grid v27.3.x
1341
- colDef === null || colDef === void 0 ? void 0 : colDef.defaultAggFunc) !== null && _e !== void 0 ? _e : 'sum'
1342
- : aggregationFunctionsColumnsMap[colId];
1329
+ let aggFunc = null;
1330
+ const aggFuncFromLayout = aggregationFunctionsColumnsMap[colId];
1331
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(colId);
1332
+ if (aggFuncFromLayout === true) {
1333
+ // if we have true, it means - take the default aggFunc from colDef
1334
+ // NOTE: colState gives us the current aggFunc, which can be null,
1335
+ // while the colDef gives us the initially configured aggFunc for that column
1336
+ aggFunc =
1337
+ (_e = (_d = (_c = colState.aggFunc) !== null && _c !== void 0 ? _c : colDef === null || colDef === void 0 ? void 0 : colDef.aggFunc) !== null && _d !== void 0 ? _d :
1338
+ // @ts-ignore available only wth ag-Grid v27.3.x
1339
+ colDef === null || colDef === void 0 ? void 0 : colDef.defaultAggFunc) !== null && _e !== void 0 ? _e : 'sum';
1340
+ }
1341
+ else if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage') {
1342
+ aggFunc = AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME;
1343
+ }
1344
+ else if (typeof aggFuncFromLayout === 'string') {
1345
+ aggFunc = aggFuncFromLayout;
1346
+ }
1347
+ newColState.aggFunc = aggFunc;
1343
1348
  }
1344
1349
  if (sortModelMap[colId]) {
1345
1350
  newColState.sort = sortModelMap[colId].sort;
@@ -1524,7 +1529,8 @@ class Adaptable {
1524
1529
  layout.ColumnSorts = columnSorts;
1525
1530
  layout.RowGroupedColumns = groupedColumns;
1526
1531
  if (Object.keys(aggregatedColumns).length) {
1527
- layout.AggregationColumns = aggregatedColumns;
1532
+ // ag-grid aggregations are not 1-1 with adaptable column-aggregations
1533
+ layout.AggregationColumns = this.handleUpdateWeightedAvgFromGrid(aggregatedColumns);
1528
1534
  }
1529
1535
  layout.EnablePivot = this.gridOptions.columnApi.isPivotMode();
1530
1536
  layout.PivotColumns = pivotColumns;
@@ -1948,7 +1954,10 @@ class Adaptable {
1948
1954
  return typeof rawValue !== 'string' ? String(rawValue) : rawValue;
1949
1955
  }
1950
1956
  if (dataType === 'Number') {
1951
- return typeof rawValue !== 'number' ? Number(rawValue) : rawValue;
1957
+ // empty string or space should not be converted to 0
1958
+ return typeof rawValue !== 'number' && StringExtensions_1.StringExtensions.IsNumeric(rawValue)
1959
+ ? Number(rawValue)
1960
+ : rawValue;
1952
1961
  }
1953
1962
  if (dataType === 'Boolean') {
1954
1963
  return typeof rawValue !== 'boolean' ? Boolean(rawValue) : rawValue;
@@ -2025,7 +2034,9 @@ class Adaptable {
2025
2034
  getAllRowNodes(config) {
2026
2035
  let rowNodes = [];
2027
2036
  this.gridOptions.api.forEachNode((rowNode, rowIndex) => {
2028
- if (!this.isGroupRowNode(rowNode) || (config === null || config === void 0 ? void 0 : config.includeGroupRows)) {
2037
+ const includeGroupRows = (config === null || config === void 0 ? void 0 : config.includeGroupRows) || !this.isGroupRowNode(rowNode);
2038
+ const filterFnFulfilled = !(config === null || config === void 0 ? void 0 : config.filterFn) || (config === null || config === void 0 ? void 0 : config.filterFn(rowNode));
2039
+ if (includeGroupRows && filterFnFulfilled) {
2029
2040
  rowNodes.push(rowNode);
2030
2041
  }
2031
2042
  });
@@ -2080,6 +2091,9 @@ class Adaptable {
2080
2091
  this.gridOptions.api.redrawRows();
2081
2092
  this._emit('GridRefreshed');
2082
2093
  }
2094
+ redrawRenderedRows() {
2095
+ this.redrawRows(this.gridOptions.api.getRenderedNodes());
2096
+ }
2083
2097
  redrawHeader() {
2084
2098
  this.gridOptions.api.refreshHeader();
2085
2099
  }
@@ -2130,8 +2144,7 @@ class Adaptable {
2130
2144
  ];
2131
2145
  }
2132
2146
  getColDefsForFreeTextColumns() {
2133
- const specialColumnsAreFilterable = this.api.internalApi.getAdaptableOptions().filterOptions.enableFilterOnSpecialColumns;
2134
- const defaultFreeTextColumnSettings = ObjectFactory_1.CreateEmptyFreeTextColumn(specialColumnsAreFilterable).FreeTextColumnSettings;
2147
+ const defaultFreeTextColumnSettings = ObjectFactory_1.CreateEmptyFreeTextColumn().FreeTextColumnSettings;
2135
2148
  return this.api.freeTextColumnApi.getAllFreeTextColumn().map((freeTextColumn) => {
2136
2149
  var _a;
2137
2150
  const freeTextColumnSettings = Object.assign(Object.assign({}, defaultFreeTextColumnSettings), freeTextColumn.FreeTextColumnSettings);
@@ -2181,10 +2194,31 @@ class Adaptable {
2181
2194
  return newColDef;
2182
2195
  });
2183
2196
  }
2184
- setupColumnValueGetter({ col }) {
2185
- // need this here if we want plugins to intercept
2197
+ setupColumnValueGetter({ col, abColumn }) {
2186
2198
  this.setColDefProperty(col, 'valueGetter', (userValue) => {
2187
- return userValue;
2199
+ return (params) => {
2200
+ const columnId = abColumn.columnId;
2201
+ let evaluatedUserValue = userValue;
2202
+ if (typeof userValue === 'function') {
2203
+ evaluatedUserValue = userValue(params);
2204
+ }
2205
+ const defaultValue = evaluatedUserValue
2206
+ ? evaluatedUserValue
2207
+ : (params === null || params === void 0 ? void 0 : params.data)
2208
+ ? params.data[columnId]
2209
+ : undefined;
2210
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
2211
+ if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage' && !params.node.group) {
2212
+ const weightedColumnId = adaptableAggFunc.weightedColumnId;
2213
+ return {
2214
+ [columnId]: defaultValue,
2215
+ [weightedColumnId]: params.data[weightedColumnId],
2216
+ toString: () => (defaultValue ? `${defaultValue}` : ''),
2217
+ valueOf: () => defaultValue,
2218
+ };
2219
+ }
2220
+ return defaultValue;
2221
+ };
2188
2222
  });
2189
2223
  }
2190
2224
  setupColumnAggFunc({ col }) {
@@ -2372,45 +2406,8 @@ class Adaptable {
2372
2406
  this.safeSetColDefs(resultColDefs);
2373
2407
  this.setLayout();
2374
2408
  }
2375
- cleanupFloatingFilters_WORKAROUND() {
2376
- // since AG Grid v26.2.0 floating filters have a memory leak due to an dangling reference to an obsolete agSetFilter instance
2377
- var _a, _b;
2378
- // 1a. The initial floating filter component is defaulted to the 'agSetColumnFloatingFilter'
2379
- // (see https://github.com/ag-grid/ag-grid/blob/v26.2.0/community-modules/core/src/ts/headerRendering/cells/floatingFilter/headerFilterCellCtrl.ts#L210) and a corresponding bean component is instantiated.
2380
- // 1b. A listener to the 'filterChanged' event is created, referencing the newly created bean instance: https://github.com/ag-grid/ag-grid/blob/v26.2.0/community-modules/core/src/ts/headerRendering/cells/floatingFilter/headerFilterCellCtrl.ts#L298
2381
- // 2a. The floating filter is set to a custom component (via https://www.ag-grid.com/javascript-data-grid/column-properties/#reference-filtering-floatingFilterComponent), triggering the creation of a new floating filter bean component
2382
- // 2b. Another listener to the 'filterChanged' event is created, referencing the newly created (in step 2a) bean instance https://github.com/ag-grid/ag-grid/blob/v26.2.0/community-modules/core/src/ts/headerRendering/cells/floatingFilter/headerFilterCellCtrl.ts#L298
2383
- // BUT the listener created in step 1b is NOT destroyed, leading to a state where the 'filterChanged' event has listeners stemming from both the current floating filter bean but also from the initial(now obsolete) bean
2384
- //
2385
- // As a consequence, any 'filterChanged' event will be processed by both listeners (1b, 2b) and will more often than not lead to a runtime exception due to the dangling references from the obsolete listener
2386
- // AG Grid team tracks this issue in AG-6179
2387
- // until a fix arrives, a workaround is to hide all the visible columns (thus destroying all the HeaderFilterCellCtrl instances)
2388
- if (!((_b = (_a = this.adaptableOptions) === null || _a === void 0 ? void 0 : _a.filterOptions) === null || _b === void 0 ? void 0 : _b.useAdaptableQuickFilter)) {
2389
- // no need to do anything if we don't use adaptable quick filter
2390
- return;
2391
- }
2392
- if (this.gridOptions.columnApi.isPivotMode()) {
2393
- // floating filters are NOT available in pivot mode
2394
- return;
2395
- }
2396
- // floating filter instances (HeaderFilterCellCtrl) are created only for rendered columns (in viewport)
2397
- // so we have to handle only the displayed columns
2398
- const allDisplayedCols = this.gridOptions.columnApi.getAllDisplayedColumns();
2399
- const colsWithFloatingFilter = allDisplayedCols.filter((col) => {
2400
- const colDef = col.getColDef();
2401
- return (colDef.floatingFilter ||
2402
- colDef.floatingFilterComponent ||
2403
- this.api.columnApi.usesAdaptableQuickFilter(col.getColId()));
2404
- });
2405
- colsWithFloatingFilter.forEach((col) => this.gridOptions.columnApi.setColumnsVisible(colsWithFloatingFilter, false));
2406
- // !! it is important to NOT set the columns visible again as this is already taken care of in the next performed method (this.updateColDefsForSpecialColumns())
2407
- }
2408
2409
  getColDefsForCalculatedColumns() {
2409
- const specialColumnsAreFilterable = this.adaptableOptions.filterOptions
2410
- .enableFilterOnSpecialColumns
2411
- ? this.adaptableOptions.filterOptions.enableFilterOnSpecialColumns
2412
- : true;
2413
- const defaultCalculatedColumnSettings = ObjectFactory_1.CreateEmptyCalculatedColumn(specialColumnsAreFilterable).CalculatedColumnSettings;
2410
+ const defaultCalculatedColumnSettings = ObjectFactory_1.CreateEmptyCalculatedColumn().CalculatedColumnSettings;
2414
2411
  const isExternalEvaluation = !this.api.internalApi.runModuleInAdaptableQL('CalculatedColumn');
2415
2412
  return this.api.calculatedColumnApi.getAllCalculatedColumn().map((calculatedColumn) => {
2416
2413
  const calculatedColumnSettings = Object.assign(Object.assign({}, defaultCalculatedColumnSettings), calculatedColumn.CalculatedColumnSettings);
@@ -2539,7 +2536,23 @@ class Adaptable {
2539
2536
  this.throttleFilterOnTickingDataChange = null;
2540
2537
  this.gridOptions.api.__adaptable = null;
2541
2538
  this.gridOptions.api.setColumnDefs = GridApi_setColumnDefs;
2542
- this.gridOptions.getRowStyle = null;
2539
+ this.revertGridOptionsPropertiesToUserValue([
2540
+ 'getRowStyle',
2541
+ 'getRowClass',
2542
+ 'excelStyles',
2543
+ 'suppressAggFuncInHeader',
2544
+ 'initialGroupOrderComparator',
2545
+ 'getContextMenuItems',
2546
+ 'getMainMenuItems',
2547
+ 'isExternalFilterPresent',
2548
+ 'doesExternalFilterPass',
2549
+ 'statusBar',
2550
+ 'sideBar',
2551
+ 'aggFuncs',
2552
+ ]);
2553
+ if (this.gridOptions.components) {
2554
+ this.gridOptions.components.AdaptableToolPanel = null;
2555
+ }
2543
2556
  if (config && config.destroyApi === false) {
2544
2557
  }
2545
2558
  else {
@@ -2559,6 +2572,8 @@ class Adaptable {
2559
2572
  this.emitter.destroy();
2560
2573
  this.emitter = null;
2561
2574
  this._adaptableReady = false;
2575
+ this.agGridHelper.destroy();
2576
+ this.agGridMenuHelper.destroy();
2562
2577
  Adaptable.dismissInstance(this);
2563
2578
  const abContainerElement = this.getAdaptableContainerElement();
2564
2579
  if (config && !config.unmount) {
@@ -2893,74 +2908,76 @@ class Adaptable {
2893
2908
  },
2894
2909
  };
2895
2910
  // We plug our filter mechanism and if there is already something like external widgets... we save ref to the function
2896
- const original_isExternalFilterPresent = this.gridOptions.isExternalFilterPresent;
2897
- this.gridOptions.isExternalFilterPresent = (params) => {
2898
- if (this.isDestroyed) {
2899
- return true;
2900
- }
2901
- const columnFilters = this.api.filterApi.getColumnFilters();
2902
- const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2903
- const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2904
- return (isFilterActive ||
2905
- isQueryActive ||
2906
- // it means that originaldoesExternalFilterPass will be called so we reinit that collection
2907
- (original_isExternalFilterPresent ? original_isExternalFilterPresent(params) : false));
2908
- };
2909
- const originaldoesExternalFilterPass = this.gridOptions.doesExternalFilterPass;
2911
+ this.setGridOptionsProperty('isExternalFilterPresent', (originalIsExternalFilterPresent) => {
2912
+ return (params) => {
2913
+ if (this.isDestroyed) {
2914
+ return true;
2915
+ }
2916
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2917
+ const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2918
+ const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2919
+ return (isFilterActive ||
2920
+ isQueryActive ||
2921
+ // it means that originalIsExternalFilterPresent will be called so we reinit that collection
2922
+ (originalIsExternalFilterPresent ? originalIsExternalFilterPresent(params) : false));
2923
+ };
2924
+ });
2910
2925
  const evaluateQueryOnClient = this.api.internalApi.runModuleInAdaptableQL('Query');
2911
2926
  const evaluateFilterOnClient = this.api.internalApi.runModuleInAdaptableQL('Filter');
2912
- this.gridOptions.doesExternalFilterPass = (node) => {
2913
- if (this.isDestroyed) {
2914
- return true;
2915
- }
2916
- // first we assess Query (if its running locally)
2917
- if (evaluateQueryOnClient && !this.isGroupRowNode(node)) {
2918
- const currentQuery = this.api.queryApi.getCurrentQuery();
2919
- if (currentQuery) {
2920
- const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2921
- if (!isCurrentQueryValid ||
2922
- !this.api.internalApi
2923
- .getQueryLanguageService()
2924
- .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2925
- return false;
2927
+ this.setGridOptionsProperty('doesExternalFilterPass', (originalDoesExternalFilterPass) => {
2928
+ return (node) => {
2929
+ if (this.isDestroyed) {
2930
+ return true;
2931
+ }
2932
+ // first we assess Query (if its running locally)
2933
+ if (evaluateQueryOnClient && !this.isGroupRowNode(node)) {
2934
+ const currentQuery = this.api.queryApi.getCurrentQuery();
2935
+ if (currentQuery) {
2936
+ const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2937
+ if (!isCurrentQueryValid ||
2938
+ !this.api.internalApi
2939
+ .getQueryLanguageService()
2940
+ .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2941
+ return false;
2942
+ }
2926
2943
  }
2927
2944
  }
2928
- }
2929
- try {
2930
- // we then assess filters (if running locally)
2931
- if (evaluateFilterOnClient) {
2932
- const columnFilters = this.api.filterApi.getColumnFilters();
2933
- if (columnFilters.length > 0) {
2934
- for (const columnFilter of columnFilters) {
2935
- if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2936
- return false;
2945
+ try {
2946
+ // we then assess filters (if running locally)
2947
+ if (evaluateFilterOnClient) {
2948
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2949
+ if (columnFilters.length > 0) {
2950
+ for (const columnFilter of columnFilters) {
2951
+ if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2952
+ return false;
2953
+ }
2937
2954
  }
2938
2955
  }
2939
2956
  }
2940
2957
  }
2941
- }
2942
- catch (ex) {
2943
- LoggingHelper_1.LogAdaptableError(ex);
2944
- return false;
2945
- }
2946
- return originaldoesExternalFilterPass ? originaldoesExternalFilterPass(node) : true;
2947
- };
2948
- // Build the COLUMN MENU. Note that we do this EACH time the menu is opened (as items can change)
2949
- const originalgetMainMenuItems = this.gridOptions.getMainMenuItems;
2950
- this.gridOptions.getMainMenuItems = (params) => {
2951
- // couldnt find a way to listen for menu close. There is a Menu Item Select, but you can also close menu from filter and clicking outside menu....
2952
- return this.agGridMenuHelper.buildColumnMenu(params, originalgetMainMenuItems);
2953
- };
2954
- // Build the CONTEXT MENU. Again we do this each time a cell is right clicked as its context-sensitive
2955
- const originalgetContextMenuItems = this.gridOptions.getContextMenuItems;
2956
- this.gridOptions.getContextMenuItems = (params) => {
2957
- return this.agGridMenuHelper.buildContextMenu(params, originalgetContextMenuItems);
2958
- };
2958
+ catch (ex) {
2959
+ LoggingHelper_1.LogAdaptableError(ex);
2960
+ return false;
2961
+ }
2962
+ return originalDoesExternalFilterPass ? originalDoesExternalFilterPass(node) : true;
2963
+ };
2964
+ });
2965
+ this.setGridOptionsProperty('getMainMenuItems', (userPropertyValue) => {
2966
+ return (params) => {
2967
+ // couldnt find a way to listen for menu close. There is a Menu Item Select, but you can also close menu from filter and clicking outside menu....
2968
+ return this.agGridMenuHelper.buildColumnMenu(params, userPropertyValue);
2969
+ };
2970
+ });
2971
+ this.setGridOptionsProperty('getContextMenuItems', (userPropertyValue) => {
2972
+ return (params) => {
2973
+ return this.agGridMenuHelper.buildContextMenu(params, userPropertyValue);
2974
+ };
2975
+ });
2959
2976
  this.prepareGrid();
2960
2977
  }
2961
2978
  updateColumnFilterActiveState() {
2962
2979
  var _a;
2963
- const columnFilters = this.api.filterApi.getColumnFilters();
2980
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2964
2981
  const activeFilters = (_a = columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.filter) === null || _a === void 0 ? void 0 : _a.call(columnFilters, (columnFilter) => this.api.filterApi.isFilterActive(columnFilter));
2965
2982
  const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(activeFilters);
2966
2983
  const columnsWithActiveFilters = {};
@@ -3042,6 +3059,7 @@ class Adaptable {
3042
3059
  this.setupColumnCellEditor(colSetupInfo);
3043
3060
  this.setupColumnHeader(colSetupInfo);
3044
3061
  this.setupColumnQuickFilerText(colSetupInfo);
3062
+ this.setupAllowedAggFuncs(colSetupInfo);
3045
3063
  });
3046
3064
  this.setupRowStyling();
3047
3065
  // setupAggregationColumnHeaders() is executed on every setLayout()
@@ -3051,6 +3069,14 @@ class Adaptable {
3051
3069
  this.redrawBody();
3052
3070
  this.redrawHeader();
3053
3071
  }
3072
+ revertGridOptionsPropertiesToUserValue(propertyNames) {
3073
+ for (const propertyName of propertyNames) {
3074
+ // see this.setGridOptionsProperty(...)
3075
+ const userKey = `user.${propertyName}`;
3076
+ const userValue = this.gridOptionsPropertyCache.get(userKey);
3077
+ this.gridOptions[propertyName] = userValue;
3078
+ }
3079
+ }
3054
3080
  setGridOptionsProperty(propertyName, propertyGetter) {
3055
3081
  if (this.isDestroyed) {
3056
3082
  return;
@@ -3289,6 +3315,11 @@ class Adaptable {
3289
3315
  };
3290
3316
  });
3291
3317
  }
3318
+ setupAllowedAggFuncs({ col, abColumn }) {
3319
+ this.setColDefProperty(col, 'allowedAggFuncs', () => {
3320
+ return abColumn.availableAggregationFunctions;
3321
+ });
3322
+ }
3292
3323
  setupColumnHeader({ col, abColumn }) {
3293
3324
  var _a, _b;
3294
3325
  const previousColumnHeader = (_a = col === null || col === void 0 ? void 0 : col.getColDef()) === null || _a === void 0 ? void 0 : _a.headerName;
@@ -3486,11 +3517,6 @@ class Adaptable {
3486
3517
  applyCurrentTheme() {
3487
3518
  this.api.themeApi.applyCurrentTheme();
3488
3519
  }
3489
- getInitialGroupOrderComparator(gridOptions) {
3490
- var _a, _b;
3491
- // fallback to deprecated forms
3492
- return ((_b = (_a = gridOptions.initialGroupOrderComparator) !== null && _a !== void 0 ? _a : gridOptions.defaultGroupOrderComparator) !== null && _b !== void 0 ? _b : gridOptions.defaultGroupSortComparator);
3493
- }
3494
3520
  applyFinalRendering() {
3495
3521
  this.embedColumnMenu = this.isModulePresent('menu');
3496
3522
  if (this.gridOptions.treeData && this.gridOptions.treeData == true) {
@@ -4624,6 +4650,54 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4624
4650
  }
4625
4651
  return this.gridOptions.api.getChartModels();
4626
4652
  }
4653
+ getActiveAdaptableAggFuncForCol(columnId) {
4654
+ if (!columnId) {
4655
+ return null;
4656
+ }
4657
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4658
+ const aggregationFunctionsColumnsMap = currentLayout.AggregationColumns || {};
4659
+ const adaptableAggFunc = aggregationFunctionsColumnsMap[columnId];
4660
+ if (typeof adaptableAggFunc === 'object' &&
4661
+ 'type' in adaptableAggFunc &&
4662
+ adaptableAggFunc.type === 'weightedAverage') {
4663
+ return adaptableAggFunc;
4664
+ }
4665
+ return null;
4666
+ }
4667
+ registerAdaptableAggFuncs() {
4668
+ this.setGridOptionsProperty('aggFuncs', (originalAggFuncs) => {
4669
+ const aggregationFunctions = originalAggFuncs || {};
4670
+ aggregationFunctions[AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME] = (params) => {
4671
+ const columnId = params.column.getColId();
4672
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
4673
+ if (!adaptableAggFunc) {
4674
+ return undefined;
4675
+ }
4676
+ if (adaptableAggFunc.type === 'weightedAverage') {
4677
+ return weightedAverage_1.weightedAverage(params, params.colDef.colId, adaptableAggFunc.weightedColumnId);
4678
+ }
4679
+ return undefined;
4680
+ };
4681
+ return aggregationFunctions;
4682
+ });
4683
+ }
4684
+ /**
4685
+ * When reading the state from the grid, we have to make sure 'avg' is not overriden with the 'avg' string.
4686
+ */
4687
+ handleUpdateWeightedAvgFromGrid(aggFuncFromGrid) {
4688
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4689
+ return Object.entries(aggFuncFromGrid).reduce((acc, [colId, agg]) => {
4690
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(colId);
4691
+ if ((adaptableAggFunc === null || adaptableAggFunc === void 0 ? void 0 : adaptableAggFunc.type) === 'weightedAverage' && agg === AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME) {
4692
+ // do not override the agg func
4693
+ acc[colId] = currentLayout.AggregationColumns[colId];
4694
+ }
4695
+ else {
4696
+ acc[colId] = agg;
4697
+ }
4698
+ return acc;
4699
+ }, {});
4700
+ }
4627
4701
  }
4628
4702
  exports.Adaptable = Adaptable;
4629
4703
  class AdaptableNoCodeWizard {
@@ -16,6 +16,7 @@ export declare class agGridHelper {
16
16
  private gridOptions;
17
17
  private initialAgGridColDefs;
18
18
  constructor(adaptable: IAdaptable, gridOptions: GridOptions);
19
+ destroy(): void;
19
20
  getAgGridLightThemeName(): string;
20
21
  getAgGridDarkThemeName(): string;
21
22
  setUpModules(): Map<AdaptableModule, IModule>;
@@ -41,8 +41,8 @@ const PercentBarRenderer_1 = require("./PercentBarRenderer");
41
41
  const Helper_1 = require("../Utilities/Helpers/Helper");
42
42
  const StatusBarModule_1 = require("../Strategy/StatusBarModule");
43
43
  const GeneralConstants = tslib_1.__importStar(require("../Utilities/Constants/GeneralConstants"));
44
- const UIHelper_1 = tslib_1.__importDefault(require("../View/UIHelper"));
45
44
  const GeneralConstants_1 = require("../Utilities/Constants/GeneralConstants");
45
+ const UIHelper_1 = tslib_1.__importDefault(require("../View/UIHelper"));
46
46
  const tinycolor = require('tinycolor2');
47
47
  /**
48
48
  * Adaptable AG Grid implementation is getting really big and unwieldy
@@ -55,8 +55,10 @@ class agGridHelper {
55
55
  this.adaptable = adaptable;
56
56
  this.gridOptions = gridOptions;
57
57
  this.initialAgGridColDefs = {};
58
- this.adaptable = adaptable;
59
- this.gridOptions = gridOptions;
58
+ }
59
+ destroy() {
60
+ this.adaptable = null;
61
+ this.gridOptions = null;
60
62
  }
61
63
  getAgGridLightThemeName() {
62
64
  // we try not to call these two methods, as we try to detect the default grid
@@ -6,6 +6,7 @@ export declare class agGridMenuHelper {
6
6
  private adaptable;
7
7
  private gridOptions;
8
8
  constructor(adaptable: IAdaptable, gridOptions: GridOptions);
9
+ destroy(): void;
9
10
  buildColumnMenu(params: GetMainMenuItemsParams, originalgetMainMenuItems: GetMainMenuItems): (string | MenuItemDef)[];
10
11
  buildContextMenu(params: GetContextMenuItemsParams, originalgetContextMenuItems: GetContextMenuItems): (string | MenuItemDef)[];
11
12
  createRemoveGroupsMenuItem(x: AdaptableMenuItem): MenuItemDef;
@@ -11,8 +11,10 @@ class agGridMenuHelper {
11
11
  constructor(adaptable, gridOptions) {
12
12
  this.adaptable = adaptable;
13
13
  this.gridOptions = gridOptions;
14
- this.adaptable = adaptable;
15
- this.gridOptions = gridOptions;
14
+ }
15
+ destroy() {
16
+ this.adaptable = null;
17
+ this.gridOptions = null;
16
18
  }
17
19
  buildColumnMenu(params, originalgetMainMenuItems) {
18
20
  // couldnt find a way to listen for menu close. There is a Menu Item Select, but you can also close menu from filter and clicking outside menu....
@@ -0,0 +1,6 @@
1
+ import { IAggFuncParams } from '@ag-grid-community/all-modules';
2
+ export declare const weightedAverage: (params: IAggFuncParams, columnId: string, weightColumnId: string) => {
3
+ [x: string]: number | (() => number | "");
4
+ toString: () => number | "";
5
+ valueOf: () => number;
6
+ };