@adaptabletools/adaptable 12.1.7 → 12.2.0-canary.0

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 (237) hide show
  1. package/base.css +127 -71
  2. package/bundle.cjs.js +108 -108
  3. package/index.css +145 -83
  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 +1 -0
  8. package/src/AdaptableOptions/AdaptableQLOptions.d.ts +44 -10
  9. package/src/AdaptableOptions/FilterOptions.d.ts +12 -0
  10. package/src/AdaptableOptions/FinancePluginOptions.d.ts +22 -1
  11. package/src/AdaptableOptions/LayoutOptions.d.ts +10 -1
  12. package/src/AdaptableOptions/StateOptions.d.ts +25 -12
  13. package/src/Api/ColumnApi.d.ts +5 -0
  14. package/src/Api/ExportApi.d.ts +5 -0
  15. package/src/Api/FilterApi.d.ts +23 -0
  16. package/src/Api/GridApi.d.ts +1 -0
  17. package/src/Api/Implementation/AlertApiImpl.js +1 -2
  18. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  19. package/src/Api/Implementation/ColumnApiImpl.js +5 -0
  20. package/src/Api/Implementation/ExportApiImpl.d.ts +3 -1
  21. package/src/Api/Implementation/ExportApiImpl.js +19 -3
  22. package/src/Api/Implementation/FilterApiImpl.d.ts +5 -0
  23. package/src/Api/Implementation/FilterApiImpl.js +25 -2
  24. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  25. package/src/Api/Implementation/InternalApiImpl.d.ts +3 -2
  26. package/src/Api/Implementation/InternalApiImpl.js +34 -3
  27. package/src/Api/Implementation/PredicateApiImpl.js +4 -0
  28. package/src/Api/Implementation/QueryLanguageApiImpl.d.ts +1 -0
  29. package/src/Api/Implementation/QueryLanguageApiImpl.js +14 -1
  30. package/src/Api/InternalApi.d.ts +6 -2
  31. package/src/Api/QueryLanguageApi.d.ts +5 -0
  32. package/src/PredefinedConfig/CalculatedColumnState.d.ts +2 -2
  33. package/src/PredefinedConfig/Common/AdaptablePredicate.js +16 -4
  34. package/src/PredefinedConfig/Common/AdaptableQuery.js +1 -1
  35. package/src/PredefinedConfig/Common/AggregationColumns.d.ts +6 -0
  36. package/src/PredefinedConfig/Common/AggregationColumns.js +4 -0
  37. package/src/PredefinedConfig/Common/ColumnFilter.d.ts +2 -2
  38. package/src/PredefinedConfig/Common/Enums.d.ts +0 -15
  39. package/src/PredefinedConfig/Common/Enums.js +1 -18
  40. package/src/PredefinedConfig/ExportState.d.ts +12 -4
  41. package/src/PredefinedConfig/LayoutState.d.ts +2 -1
  42. package/src/PredefinedConfig/PopupState.d.ts +1 -2
  43. package/src/Redux/ActionsReducers/AlertRedux.d.ts +1 -1
  44. package/src/Redux/ActionsReducers/AlertRedux.js +1 -1
  45. package/src/Redux/ActionsReducers/ConditionalStyleRedux.d.ts +1 -1
  46. package/src/Redux/ActionsReducers/ConditionalStyleRedux.js +1 -1
  47. package/src/Redux/ActionsReducers/CustomSortRedux.d.ts +1 -1
  48. package/src/Redux/ActionsReducers/CustomSortRedux.js +1 -1
  49. package/src/Redux/ActionsReducers/FlashingCellRedux.d.ts +1 -1
  50. package/src/Redux/ActionsReducers/FlashingCellRedux.js +1 -1
  51. package/src/Redux/ActionsReducers/FormatColumnRedux.d.ts +1 -1
  52. package/src/Redux/ActionsReducers/FormatColumnRedux.js +1 -1
  53. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +28 -0
  54. package/src/Redux/ActionsReducers/LayoutRedux.js +80 -2
  55. package/src/Redux/ActionsReducers/PlusMinusRedux.d.ts +1 -1
  56. package/src/Redux/ActionsReducers/PlusMinusRedux.js +1 -1
  57. package/src/Redux/ActionsReducers/PopupRedux.d.ts +0 -2
  58. package/src/Redux/ActionsReducers/PopupRedux.js +1 -28
  59. package/src/Redux/ActionsReducers/ScheduleRedux.d.ts +5 -5
  60. package/src/Redux/ActionsReducers/ScheduleRedux.js +5 -5
  61. package/src/Redux/ActionsReducers/ShortcutRedux.d.ts +1 -1
  62. package/src/Redux/ActionsReducers/ShortcutRedux.js +1 -1
  63. package/src/Redux/Store/AdaptableStore.js +15 -6
  64. package/src/Strategy/AlertModule.d.ts +1 -0
  65. package/src/Strategy/AlertModule.js +20 -0
  66. package/src/Strategy/BulkUpdateModule.d.ts +1 -1
  67. package/src/Strategy/CalculatedColumnModule.js +3 -3
  68. package/src/Strategy/ExportModule.d.ts +0 -1
  69. package/src/Strategy/ExportModule.js +0 -16
  70. package/src/Strategy/FilterModule.js +6 -0
  71. package/src/Strategy/Interface/IModule.d.ts +4 -0
  72. package/src/Strategy/LayoutModule.js +20 -20
  73. package/src/Strategy/QueryModule.js +1 -1
  74. package/src/Strategy/Utilities/Export/getExportRowsViewItems.js +0 -13
  75. package/src/Strategy/Utilities/FormatColumn/getFormatColumnStyleViewItems.js +16 -1
  76. package/src/Strategy/Utilities/Layout/getLayoutFilterViewItems.js +15 -11
  77. package/src/Strategy/Utilities/getExpressionViewItems.d.ts +3 -4
  78. package/src/Strategy/Utilities/getExpressionViewItems.js +3 -3
  79. package/src/Strategy/Utilities/getRuleViewItems.js +1 -1
  80. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +1 -0
  81. package/src/Utilities/Constants/DocumentationLinkConstants.js +2 -1
  82. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +3 -0
  83. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.d.ts +12 -2
  84. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.js +30 -66
  85. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +22 -6
  86. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +423 -220
  87. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +7 -1
  88. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +25 -7
  89. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +0 -1
  90. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +6 -54
  91. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.d.ts +1 -1
  92. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +31 -5
  93. package/src/Utilities/Interface/MessagePopups.d.ts +0 -4
  94. package/src/Utilities/ObjectFactory.d.ts +4 -2
  95. package/src/Utilities/ObjectFactory.js +16 -3
  96. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +25 -0
  97. package/src/Utilities/Services/AggregatedScalarLiveValue.js +103 -0
  98. package/src/Utilities/Services/AlertService.d.ts +0 -1
  99. package/src/Utilities/Services/AlertService.js +5 -17
  100. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +4 -4
  101. package/src/Utilities/Services/CalculatedColumnExpressionService.js +29 -154
  102. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +2 -2
  103. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +8 -3
  104. package/src/Utilities/Services/QueryLanguageService.d.ts +8 -4
  105. package/src/Utilities/Services/QueryLanguageService.js +68 -25
  106. package/src/Utilities/Services/ReportService.js +48 -48
  107. package/src/View/AdaptableView.js +1 -2
  108. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/AdaptableOptionsForm.d.ts +1 -1
  109. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/AdaptableOptionsForm.js +10 -10
  110. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/Components/FormBox.d.ts +3 -0
  111. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/Components/FormBox.js +9 -0
  112. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.js +14 -15
  113. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/EntitlementsForm.d.ts +1 -1
  114. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/EntitlementsForm.js +2 -2
  115. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/FinanceForm/FinanceForm.d.ts +7 -0
  116. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/FinanceForm/FinanceForm.js +280 -0
  117. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/FinanceForm/index.d.ts +1 -0
  118. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/FinanceForm/index.js +5 -0
  119. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/GridOptionsForm.d.ts +1 -1
  120. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/GridOptionsForm.js +4 -4
  121. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/UIOptions/UIOptionsStatusbarForm.js +2 -8
  122. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/UIOptions/UiOptionsForm.d.ts +1 -1
  123. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/UIOptions/UiOptionsForm.js +3 -3
  124. package/src/View/AdaptableWizardView/Wizard.js +2 -2
  125. package/src/View/CalculatedColumn/CalculatedColumnSummary.d.ts +0 -1
  126. package/src/View/CalculatedColumn/CalculatedColumnSummary.js +1 -8
  127. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingsTags.d.ts +2 -0
  128. package/src/View/CalculatedColumn/Utilities/{getCalculatedColumnSettingTags.js → getCalculatedColumnSettingsTags.js} +3 -3
  129. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.d.ts +10 -0
  130. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.js +80 -0
  131. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +24 -14
  132. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.d.ts +1 -2
  133. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +9 -52
  134. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +17 -6
  135. package/src/View/Components/AdaptableObjectCollection/index.d.ts +3 -4
  136. package/src/View/Components/AdaptableObjectCollection/index.js +7 -8
  137. package/src/View/Components/AdaptableObjectList/AdaptableObjectCompactList.js +42 -6
  138. package/src/View/Components/AdaptableObjectList/AdaptableObjectList.js +1 -1
  139. package/src/View/Components/AdaptableObjectRow/index.js +1 -4
  140. package/src/View/Components/EntityRulesEditor/index.js +28 -7
  141. package/src/View/Components/FilterForm/FilterForm.js +8 -4
  142. package/src/View/Components/FilterForm/ListBoxFilterForm.js +1 -0
  143. package/src/View/Components/FilterForm/QuickFilterForm.js +19 -7
  144. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.d.ts +9 -0
  145. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.js +28 -0
  146. package/src/View/Components/PermittedValuesSelector/index.d.ts +1 -0
  147. package/src/View/Components/PermittedValuesSelector/index.js +5 -0
  148. package/src/View/Components/Popups/AdaptablePopup/Navigation.js +2 -2
  149. package/src/View/Components/Popups/AdaptablePopup/PopupPanel.d.ts +1 -0
  150. package/src/View/Components/Popups/AdaptablePopup/PopupPanel.js +2 -1
  151. package/src/View/Components/Popups/AdaptableToaster.js +2 -7
  152. package/src/View/Components/Popups/WindowPopups/windowFactory.d.ts +0 -1
  153. package/src/View/Components/Popups/WindowPopups/windowFactory.js +1 -4
  154. package/src/View/Components/ValueSelector/index.js +8 -19
  155. package/src/View/CustomSort/CustomSortSummary.js +1 -1
  156. package/src/View/Dashboard/DashboardPopup.js +11 -10
  157. package/src/View/Export/ExportViewPanel.d.ts +1 -2
  158. package/src/View/Export/ExportViewPanel.js +4 -8
  159. package/src/View/Export/Wizard/ReportColumnTypeWizard.d.ts +1 -2
  160. package/src/View/Export/Wizard/ReportColumnTypeWizard.js +11 -12
  161. package/src/View/Export/Wizard/ReportRowTypeWizard.d.ts +1 -2
  162. package/src/View/Export/Wizard/ReportRowTypeWizard.js +12 -13
  163. package/src/View/Export/Wizard/ReportRowsWizardSection.js +4 -3
  164. package/src/View/Export/Wizard/ReportSettingsWizard.js +1 -2
  165. package/src/View/Filter/FilterViewPanel.js +21 -4
  166. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  167. package/src/View/GridInfo/AdaptableObjectsSummary.js +5 -3
  168. package/src/View/GridInfo/AdaptableOptionsComponent.js +1 -1
  169. package/src/View/GridInfo/GridInfoPopup.js +6 -7
  170. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.d.ts +0 -0
  171. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.js +0 -0
  172. package/src/View/Layout/Wizard/LayoutWizard.js +1 -0
  173. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +1 -0
  174. package/src/View/Layout/Wizard/sections/AggregationsSection.js +69 -8
  175. package/src/View/Layout/Wizard/sections/ColumnsSection.js +1 -1
  176. package/src/View/Query/QueryViewPanel.js +1 -1
  177. package/src/View/Query/Wizard/NamedQueryExpressionWizardSection.js +3 -4
  178. package/src/View/StateManagement/StateManagementPopup.js +18 -19
  179. package/src/agGrid/Adaptable.d.ts +12 -3
  180. package/src/agGrid/Adaptable.js +264 -148
  181. package/src/agGrid/agGridHelper.d.ts +1 -0
  182. package/src/agGrid/agGridHelper.js +5 -3
  183. package/src/agGrid/agGridMenuHelper.d.ts +1 -0
  184. package/src/agGrid/agGridMenuHelper.js +4 -2
  185. package/src/agGrid/weightedAverage.d.ts +6 -0
  186. package/src/agGrid/weightedAverage.js +66 -0
  187. package/src/bundle-dependencies/bundles/react-toastify/index.js +1 -1
  188. package/src/components/DragAndDropContext/ModuleManager.js +3 -4
  189. package/src/components/DragAndDropContext/TabList.js +9 -30
  190. package/src/components/DragAndDropContext/UnusedPanel.js +1 -7
  191. package/src/components/DropdownButton/index.js +2 -2
  192. package/src/components/EmptyContent/index.js +2 -2
  193. package/src/components/ExpressionEditor/BaseEditorInput.d.ts +1 -0
  194. package/src/components/ExpressionEditor/BaseEditorInput.js +3 -3
  195. package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
  196. package/src/components/ExpressionEditor/EditorInput.js +24 -4
  197. package/src/components/ExpressionEditor/{EditorInputReactive.d.ts → EditorInputWithWhereClause.d.ts} +3 -3
  198. package/src/components/ExpressionEditor/{EditorInputReactive.js → EditorInputWithWhereClause.js} +6 -5
  199. package/src/components/ExpressionEditor/editorButtonsAggregatedBoolean.d.ts +2 -0
  200. package/src/components/ExpressionEditor/{editorButtonsReactive.js → editorButtonsAggregatedBoolean.js} +22 -37
  201. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +5 -10
  202. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.d.ts +2 -0
  203. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.js +50 -0
  204. package/src/components/ExpressionEditor/editorButtonsObservable.d.ts +2 -0
  205. package/src/components/ExpressionEditor/editorButtonsObservable.js +40 -0
  206. package/src/components/ExpressionEditor/index.d.ts +1 -1
  207. package/src/components/ExpressionEditor/index.js +50 -19
  208. package/src/metamodel/adaptable.metamodel.d.ts +86 -5
  209. package/src/metamodel/adaptable.metamodel.js +1 -1
  210. package/src/parser/src/types.d.ts +14 -10
  211. package/src/types.d.ts +4 -4
  212. package/version.d.ts +1 -1
  213. package/version.js +1 -1
  214. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingTags.d.ts +0 -2
  215. package/src/View/Layout/LayoutEditorStandalonePopup.d.ts +0 -3
  216. package/src/View/Layout/LayoutEditorStandalonePopup.js +0 -78
  217. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.d.ts +0 -27
  218. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.js +0 -86
  219. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.d.ts +0 -16
  220. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.js +0 -89
  221. package/src/View/Layout/Wizard/LayoutEditor/PivotList.d.ts +0 -15
  222. package/src/View/Layout/Wizard/LayoutEditor/PivotList.js +0 -70
  223. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.d.ts +0 -15
  224. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.js +0 -70
  225. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.d.ts +0 -7
  226. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.js +0 -11
  227. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.d.ts +0 -6
  228. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.js +0 -26
  229. package/src/View/Layout/Wizard/LayoutEditor/index.d.ts +0 -9
  230. package/src/View/Layout/Wizard/LayoutEditor/index.js +0 -367
  231. package/src/View/Layout/Wizard/LayoutEditor/reducer.d.ts +0 -28
  232. package/src/View/Layout/Wizard/LayoutEditor/reducer.js +0 -46
  233. package/src/View/Layout/Wizard/LayoutEditor/utils.d.ts +0 -10
  234. package/src/View/Layout/Wizard/LayoutEditor/utils.js +0 -14
  235. package/src/View/Layout/Wizard/LayoutEditorWizard.d.ts +0 -30
  236. package/src/View/Layout/Wizard/LayoutEditorWizard.js +0 -132
  237. 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
  });
@@ -1310,9 +1305,11 @@ class Adaptable {
1310
1305
  }
1311
1306
  newColState.rowGroupIndex =
1312
1307
  groupedColumnsIndexesMap[colId] != null ? groupedColumnsIndexesMap[colId] : null;
1313
- // if (newColState.rowGroupIndex == null) {
1308
+ const previousRowGroup = newColState.rowGroup;
1314
1309
  newColState.rowGroup = newColState.rowGroupIndex != null;
1315
- // }
1310
+ if (!previousRowGroup && newColState.rowGroup) {
1311
+ this.triggerSetupColumnKeyCreator(colId);
1312
+ }
1316
1313
  const normalizePinned = (pinnedValue) => {
1317
1314
  if (typeof pinnedValue === 'string') {
1318
1315
  return pinnedValue;
@@ -1331,15 +1328,25 @@ class Adaptable {
1331
1328
  newColState.aggFunc = null;
1332
1329
  if (aggregationFunctionsColumnsMap[colId] != null) {
1333
1330
  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];
1331
+ let aggFunc = null;
1332
+ const aggFuncFromLayout = aggregationFunctionsColumnsMap[colId];
1333
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(colId);
1334
+ if (aggFuncFromLayout === true) {
1335
+ // if we have true, it means - take the default aggFunc from colDef
1336
+ // NOTE: colState gives us the current aggFunc, which can be null,
1337
+ // while the colDef gives us the initially configured aggFunc for that column
1338
+ aggFunc =
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
+ }
1343
+ else if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage') {
1344
+ aggFunc = AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME;
1345
+ }
1346
+ else if (typeof aggFuncFromLayout === 'string') {
1347
+ aggFunc = aggFuncFromLayout;
1348
+ }
1349
+ newColState.aggFunc = aggFunc;
1343
1350
  }
1344
1351
  if (sortModelMap[colId]) {
1345
1352
  newColState.sort = sortModelMap[colId].sort;
@@ -1524,7 +1531,8 @@ class Adaptable {
1524
1531
  layout.ColumnSorts = columnSorts;
1525
1532
  layout.RowGroupedColumns = groupedColumns;
1526
1533
  if (Object.keys(aggregatedColumns).length) {
1527
- layout.AggregationColumns = aggregatedColumns;
1534
+ // ag-grid aggregations are not 1-1 with adaptable column-aggregations
1535
+ layout.AggregationColumns = this.handleUpdateWeightedAvgFromGrid(aggregatedColumns);
1528
1536
  }
1529
1537
  layout.EnablePivot = this.gridOptions.columnApi.isPivotMode();
1530
1538
  layout.PivotColumns = pivotColumns;
@@ -2028,7 +2036,9 @@ class Adaptable {
2028
2036
  getAllRowNodes(config) {
2029
2037
  let rowNodes = [];
2030
2038
  this.gridOptions.api.forEachNode((rowNode, rowIndex) => {
2031
- if (!this.isGroupRowNode(rowNode) || (config === null || config === void 0 ? void 0 : config.includeGroupRows)) {
2039
+ const includeGroupRows = (config === null || config === void 0 ? void 0 : config.includeGroupRows) || !this.isGroupRowNode(rowNode);
2040
+ const filterFnFulfilled = !(config === null || config === void 0 ? void 0 : config.filterFn) || (config === null || config === void 0 ? void 0 : config.filterFn(rowNode));
2041
+ if (includeGroupRows && filterFnFulfilled) {
2032
2042
  rowNodes.push(rowNode);
2033
2043
  }
2034
2044
  });
@@ -2186,10 +2196,31 @@ class Adaptable {
2186
2196
  return newColDef;
2187
2197
  });
2188
2198
  }
2189
- setupColumnValueGetter({ col }) {
2190
- // need this here if we want plugins to intercept
2199
+ setupColumnValueGetter({ col, abColumn }) {
2191
2200
  this.setColDefProperty(col, 'valueGetter', (userValue) => {
2192
- return userValue;
2201
+ return (params) => {
2202
+ const columnId = abColumn.columnId;
2203
+ let evaluatedUserValue = userValue;
2204
+ if (typeof userValue === 'function') {
2205
+ evaluatedUserValue = userValue(params);
2206
+ }
2207
+ const defaultValue = evaluatedUserValue
2208
+ ? evaluatedUserValue
2209
+ : (params === null || params === void 0 ? void 0 : params.data)
2210
+ ? params.data[columnId]
2211
+ : undefined;
2212
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
2213
+ if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage' && !params.node.group) {
2214
+ const weightedColumnId = adaptableAggFunc.weightedColumnId;
2215
+ return {
2216
+ [columnId]: defaultValue,
2217
+ [weightedColumnId]: params.data[weightedColumnId],
2218
+ toString: () => (defaultValue ? `${defaultValue}` : ''),
2219
+ valueOf: () => defaultValue,
2220
+ };
2221
+ }
2222
+ return defaultValue;
2223
+ };
2193
2224
  });
2194
2225
  }
2195
2226
  setupColumnAggFunc({ col }) {
@@ -2377,42 +2408,8 @@ class Adaptable {
2377
2408
  this.safeSetColDefs(resultColDefs);
2378
2409
  this.setLayout();
2379
2410
  }
2380
- cleanupFloatingFilters_WORKAROUND() {
2381
- // since AG Grid v26.2.0 floating filters have a memory leak due to an dangling reference to an obsolete agSetFilter instance
2382
- var _a, _b;
2383
- // 1a. The initial floating filter component is defaulted to the 'agSetColumnFloatingFilter'
2384
- // (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.
2385
- // 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
2386
- // 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
2387
- // 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
2388
- // 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
2389
- //
2390
- // 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
2391
- // AG Grid team tracks this issue in AG-6179
2392
- // until a fix arrives, a workaround is to hide all the visible columns (thus destroying all the HeaderFilterCellCtrl instances)
2393
- if (!((_b = (_a = this.adaptableOptions) === null || _a === void 0 ? void 0 : _a.filterOptions) === null || _b === void 0 ? void 0 : _b.useAdaptableQuickFilter)) {
2394
- // no need to do anything if we don't use adaptable quick filter
2395
- return;
2396
- }
2397
- if (this.gridOptions.columnApi.isPivotMode()) {
2398
- // floating filters are NOT available in pivot mode
2399
- return;
2400
- }
2401
- // floating filter instances (HeaderFilterCellCtrl) are created only for rendered columns (in viewport)
2402
- // so we have to handle only the displayed columns
2403
- const allDisplayedCols = this.gridOptions.columnApi.getAllDisplayedColumns();
2404
- const colsWithFloatingFilter = allDisplayedCols.filter((col) => {
2405
- const colDef = col.getColDef();
2406
- return (colDef.floatingFilter ||
2407
- colDef.floatingFilterComponent ||
2408
- this.api.columnApi.usesAdaptableQuickFilter(col.getColId()));
2409
- });
2410
- colsWithFloatingFilter.forEach((col) => this.gridOptions.columnApi.setColumnsVisible(colsWithFloatingFilter, false));
2411
- // !! it is important to NOT set the columns visible again as this is already taken care of in the next performed method (this.updateColDefsForSpecialColumns())
2412
- }
2413
2411
  getColDefsForCalculatedColumns() {
2414
2412
  const defaultCalculatedColumnSettings = ObjectFactory_1.CreateEmptyCalculatedColumn().CalculatedColumnSettings;
2415
- const isExternalEvaluation = !this.api.internalApi.runModuleInAdaptableQL('CalculatedColumn');
2416
2413
  return this.api.calculatedColumnApi.getAllCalculatedColumn().map((calculatedColumn) => {
2417
2414
  const calculatedColumnSettings = Object.assign(Object.assign({}, defaultCalculatedColumnSettings), calculatedColumn.CalculatedColumnSettings);
2418
2415
  if (!calculatedColumnSettings.DataType) {
@@ -2426,6 +2423,7 @@ class Adaptable {
2426
2423
  if (ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(calculatedColumnSettings.ColumnTypes)) {
2427
2424
  columnTypes.push(...calculatedColumnSettings.ColumnTypes);
2428
2425
  }
2426
+ const isExternalEvaluation = !this.api.internalApi.evaluateExpressionInAdaptableQL('CalculatedColumn', this.api.queryLanguageApi.getAdaptableQueryExpression(calculatedColumn.Query));
2429
2427
  const newColDef = {
2430
2428
  headerName: calculatedColumn.FriendlyName
2431
2429
  ? calculatedColumn.FriendlyName
@@ -2455,7 +2453,7 @@ class Adaptable {
2455
2453
  if (calculatedColumnSettings.ShowToolTip != null &&
2456
2454
  calculatedColumnSettings.ShowToolTip == true) {
2457
2455
  newColDef.tooltipValueGetter = () => {
2458
- return this.api.queryLanguageApi.getAdaptableQueryExpression(calculatedColumn.Query);
2456
+ return this.api.internalApi.getAdaptableQueryExpressionText(calculatedColumn.Query);
2459
2457
  };
2460
2458
  }
2461
2459
  if (calculatedColumnSettings.HeaderToolTip) {
@@ -2540,7 +2538,23 @@ class Adaptable {
2540
2538
  this.throttleFilterOnTickingDataChange = null;
2541
2539
  this.gridOptions.api.__adaptable = null;
2542
2540
  this.gridOptions.api.setColumnDefs = GridApi_setColumnDefs;
2543
- this.gridOptions.getRowStyle = null;
2541
+ this.revertGridOptionsPropertiesToUserValue([
2542
+ 'getRowStyle',
2543
+ 'getRowClass',
2544
+ 'excelStyles',
2545
+ 'suppressAggFuncInHeader',
2546
+ 'initialGroupOrderComparator',
2547
+ 'getContextMenuItems',
2548
+ 'getMainMenuItems',
2549
+ 'isExternalFilterPresent',
2550
+ 'doesExternalFilterPass',
2551
+ 'statusBar',
2552
+ 'sideBar',
2553
+ 'aggFuncs',
2554
+ ]);
2555
+ if (this.gridOptions.components) {
2556
+ this.gridOptions.components.AdaptableToolPanel = null;
2557
+ }
2544
2558
  if (config && config.destroyApi === false) {
2545
2559
  }
2546
2560
  else {
@@ -2560,6 +2574,8 @@ class Adaptable {
2560
2574
  this.emitter.destroy();
2561
2575
  this.emitter = null;
2562
2576
  this._adaptableReady = false;
2577
+ this.agGridHelper.destroy();
2578
+ this.agGridMenuHelper.destroy();
2563
2579
  Adaptable.dismissInstance(this);
2564
2580
  const abContainerElement = this.getAdaptableContainerElement();
2565
2581
  if (config && !config.unmount) {
@@ -2894,74 +2910,78 @@ class Adaptable {
2894
2910
  },
2895
2911
  };
2896
2912
  // We plug our filter mechanism and if there is already something like external widgets... we save ref to the function
2897
- const original_isExternalFilterPresent = this.gridOptions.isExternalFilterPresent;
2898
- this.gridOptions.isExternalFilterPresent = (params) => {
2899
- if (this.isDestroyed) {
2900
- return true;
2901
- }
2902
- const columnFilters = this.api.filterApi.getColumnFilters();
2903
- const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2904
- const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2905
- return (isFilterActive ||
2906
- isQueryActive ||
2907
- // it means that originaldoesExternalFilterPass will be called so we reinit that collection
2908
- (original_isExternalFilterPresent ? original_isExternalFilterPresent(params) : false));
2909
- };
2910
- const originaldoesExternalFilterPass = this.gridOptions.doesExternalFilterPass;
2911
- const evaluateQueryOnClient = this.api.internalApi.runModuleInAdaptableQL('Query');
2912
- const evaluateFilterOnClient = this.api.internalApi.runModuleInAdaptableQL('Filter');
2913
- this.gridOptions.doesExternalFilterPass = (node) => {
2914
- if (this.isDestroyed) {
2915
- return true;
2916
- }
2917
- // first we assess Query (if its running locally)
2918
- if (evaluateQueryOnClient && !this.isGroupRowNode(node)) {
2919
- const currentQuery = this.api.queryApi.getCurrentQuery();
2920
- if (currentQuery) {
2921
- const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2922
- if (!isCurrentQueryValid ||
2923
- !this.api.internalApi
2924
- .getQueryLanguageService()
2925
- .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2926
- return false;
2927
- }
2913
+ this.setGridOptionsProperty('isExternalFilterPresent', (originalIsExternalFilterPresent) => {
2914
+ return (params) => {
2915
+ if (this.isDestroyed) {
2916
+ return true;
2928
2917
  }
2929
- }
2930
- try {
2931
- // we then assess filters (if running locally)
2932
- if (evaluateFilterOnClient) {
2933
- const columnFilters = this.api.filterApi.getColumnFilters();
2934
- if (columnFilters.length > 0) {
2935
- for (const columnFilter of columnFilters) {
2936
- if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2918
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2919
+ const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2920
+ const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2921
+ return (isFilterActive ||
2922
+ isQueryActive ||
2923
+ // it means that originalIsExternalFilterPresent will be called so we reinit that collection
2924
+ (originalIsExternalFilterPresent ? originalIsExternalFilterPresent(params) : false));
2925
+ };
2926
+ });
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 (!this.isGroupRowNode(node)) {
2934
+ const currentQuery = this.api.queryApi.getCurrentQuery();
2935
+ if (currentQuery) {
2936
+ const evaluateQueryOnClient = this.api.internalApi.evaluateExpressionInAdaptableQL('Query', currentQuery);
2937
+ if (evaluateQueryOnClient) {
2938
+ const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2939
+ if (!isCurrentQueryValid ||
2940
+ !this.api.internalApi
2941
+ .getQueryLanguageService()
2942
+ .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2937
2943
  return false;
2938
2944
  }
2939
2945
  }
2940
2946
  }
2941
2947
  }
2942
- }
2943
- catch (ex) {
2944
- LoggingHelper_1.LogAdaptableError(ex);
2945
- return false;
2946
- }
2947
- return originaldoesExternalFilterPass ? originaldoesExternalFilterPass(node) : true;
2948
- };
2949
- // Build the COLUMN MENU. Note that we do this EACH time the menu is opened (as items can change)
2950
- const originalgetMainMenuItems = this.gridOptions.getMainMenuItems;
2951
- this.gridOptions.getMainMenuItems = (params) => {
2952
- // 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....
2953
- return this.agGridMenuHelper.buildColumnMenu(params, originalgetMainMenuItems);
2954
- };
2955
- // Build the CONTEXT MENU. Again we do this each time a cell is right clicked as its context-sensitive
2956
- const originalgetContextMenuItems = this.gridOptions.getContextMenuItems;
2957
- this.gridOptions.getContextMenuItems = (params) => {
2958
- return this.agGridMenuHelper.buildContextMenu(params, originalgetContextMenuItems);
2959
- };
2948
+ const evaluateFilterOnClient = this.api.internalApi.evaluateExpressionInAdaptableQL('Filter');
2949
+ try {
2950
+ // we then assess filters (if running locally)
2951
+ if (evaluateFilterOnClient) {
2952
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2953
+ if (columnFilters.length > 0) {
2954
+ for (const columnFilter of columnFilters) {
2955
+ if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2956
+ return false;
2957
+ }
2958
+ }
2959
+ }
2960
+ }
2961
+ }
2962
+ catch (ex) {
2963
+ LoggingHelper_1.LogAdaptableError(ex);
2964
+ return false;
2965
+ }
2966
+ return originalDoesExternalFilterPass ? originalDoesExternalFilterPass(node) : true;
2967
+ };
2968
+ });
2969
+ this.setGridOptionsProperty('getMainMenuItems', (userPropertyValue) => {
2970
+ return (params) => {
2971
+ // 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....
2972
+ return this.agGridMenuHelper.buildColumnMenu(params, userPropertyValue);
2973
+ };
2974
+ });
2975
+ this.setGridOptionsProperty('getContextMenuItems', (userPropertyValue) => {
2976
+ return (params) => {
2977
+ return this.agGridMenuHelper.buildContextMenu(params, userPropertyValue);
2978
+ };
2979
+ });
2960
2980
  this.prepareGrid();
2961
2981
  }
2962
2982
  updateColumnFilterActiveState() {
2963
2983
  var _a;
2964
- const columnFilters = this.api.filterApi.getColumnFilters();
2984
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2965
2985
  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));
2966
2986
  const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(activeFilters);
2967
2987
  const columnsWithActiveFilters = {};
@@ -3043,6 +3063,8 @@ class Adaptable {
3043
3063
  this.setupColumnCellEditor(colSetupInfo);
3044
3064
  this.setupColumnHeader(colSetupInfo);
3045
3065
  this.setupColumnQuickFilerText(colSetupInfo);
3066
+ this.setupAllowedAggFuncs(colSetupInfo);
3067
+ this.setupColumnKeyCreator(colSetupInfo);
3046
3068
  });
3047
3069
  this.setupRowStyling();
3048
3070
  // setupAggregationColumnHeaders() is executed on every setLayout()
@@ -3052,6 +3074,14 @@ class Adaptable {
3052
3074
  this.redrawBody();
3053
3075
  this.redrawHeader();
3054
3076
  }
3077
+ revertGridOptionsPropertiesToUserValue(propertyNames) {
3078
+ for (const propertyName of propertyNames) {
3079
+ // see this.setGridOptionsProperty(...)
3080
+ const userKey = `user.${propertyName}`;
3081
+ const userValue = this.gridOptionsPropertyCache.get(userKey);
3082
+ this.gridOptions[propertyName] = userValue;
3083
+ }
3084
+ }
3055
3085
  setGridOptionsProperty(propertyName, propertyGetter) {
3056
3086
  if (this.isDestroyed) {
3057
3087
  return;
@@ -3290,6 +3320,49 @@ class Adaptable {
3290
3320
  };
3291
3321
  });
3292
3322
  }
3323
+ setupAllowedAggFuncs({ col, abColumn }) {
3324
+ this.setColDefProperty(col, 'allowedAggFuncs', () => {
3325
+ return abColumn.availableAggregationFunctions;
3326
+ });
3327
+ }
3328
+ triggerSetupColumnKeyCreator(colId) {
3329
+ const col = this.gridOptions.columnApi.getColumn(colId);
3330
+ const colDef = col.getColDef();
3331
+ const abColumn = this.api.columnApi.getColumnFromId(colId);
3332
+ const colSetupInfo = {
3333
+ col,
3334
+ colDef,
3335
+ colId,
3336
+ abColumn,
3337
+ };
3338
+ this.setupColumnKeyCreator(colSetupInfo);
3339
+ }
3340
+ setupColumnKeyCreator(columnSetupInfo) {
3341
+ const { col, abColumn } = columnSetupInfo;
3342
+ const adaptableOptions = this.adaptableOptions;
3343
+ const adaptableApi = this.api;
3344
+ this.setColDefProperty(col, 'keyCreator', (userPropertyValue) => {
3345
+ return (params) => {
3346
+ var _a;
3347
+ if (typeof userPropertyValue === 'function') {
3348
+ return userPropertyValue(params);
3349
+ }
3350
+ const value = params.value;
3351
+ const groupUnbalancedGroupsUnderKey = (_a = adaptableOptions.layoutOptions) === null || _a === void 0 ? void 0 : _a.groupUnbalancedGroupsUnderKey;
3352
+ if (!groupUnbalancedGroupsUnderKey) {
3353
+ return value;
3354
+ }
3355
+ let groupUnbalancedGroupsUnderKeyValue = typeof groupUnbalancedGroupsUnderKey === 'function'
3356
+ ? groupUnbalancedGroupsUnderKey({
3357
+ adaptableApi: adaptableApi,
3358
+ adaptableColumn: abColumn,
3359
+ params,
3360
+ })
3361
+ : groupUnbalancedGroupsUnderKey;
3362
+ return value === null || value === undefined ? groupUnbalancedGroupsUnderKeyValue : value;
3363
+ };
3364
+ });
3365
+ }
3293
3366
  setupColumnHeader({ col, abColumn }) {
3294
3367
  var _a, _b;
3295
3368
  const previousColumnHeader = (_a = col === null || col === void 0 ? void 0 : col.getColDef()) === null || _a === void 0 ? void 0 : _a.headerName;
@@ -3487,11 +3560,6 @@ class Adaptable {
3487
3560
  applyCurrentTheme() {
3488
3561
  this.api.themeApi.applyCurrentTheme();
3489
3562
  }
3490
- getInitialGroupOrderComparator(gridOptions) {
3491
- var _a, _b;
3492
- // fallback to deprecated forms
3493
- return ((_b = (_a = gridOptions.initialGroupOrderComparator) !== null && _a !== void 0 ? _a : gridOptions.defaultGroupOrderComparator) !== null && _b !== void 0 ? _b : gridOptions.defaultGroupSortComparator);
3494
- }
3495
3563
  applyFinalRendering() {
3496
3564
  this.embedColumnMenu = this.isModulePresent('menu');
3497
3565
  if (this.gridOptions.treeData && this.gridOptions.treeData == true) {
@@ -4625,6 +4693,54 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4625
4693
  }
4626
4694
  return this.gridOptions.api.getChartModels();
4627
4695
  }
4696
+ getActiveAdaptableAggFuncForCol(columnId) {
4697
+ if (!columnId) {
4698
+ return null;
4699
+ }
4700
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4701
+ const aggregationFunctionsColumnsMap = currentLayout.AggregationColumns || {};
4702
+ const adaptableAggFunc = aggregationFunctionsColumnsMap[columnId];
4703
+ if (typeof adaptableAggFunc === 'object' &&
4704
+ 'type' in adaptableAggFunc &&
4705
+ adaptableAggFunc.type === 'weightedAverage') {
4706
+ return adaptableAggFunc;
4707
+ }
4708
+ return null;
4709
+ }
4710
+ registerAdaptableAggFuncs() {
4711
+ this.setGridOptionsProperty('aggFuncs', (originalAggFuncs) => {
4712
+ const aggregationFunctions = originalAggFuncs || {};
4713
+ aggregationFunctions[AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME] = (params) => {
4714
+ const columnId = params.column.getColId();
4715
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
4716
+ if (!adaptableAggFunc) {
4717
+ return undefined;
4718
+ }
4719
+ if (adaptableAggFunc.type === 'weightedAverage') {
4720
+ return weightedAverage_1.weightedAverage(params, params.colDef.colId, adaptableAggFunc.weightedColumnId);
4721
+ }
4722
+ return undefined;
4723
+ };
4724
+ return aggregationFunctions;
4725
+ });
4726
+ }
4727
+ /**
4728
+ * When reading the state from the grid, we have to make sure 'avg' is not overriden with the 'avg' string.
4729
+ */
4730
+ handleUpdateWeightedAvgFromGrid(aggFuncFromGrid) {
4731
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4732
+ return Object.entries(aggFuncFromGrid).reduce((acc, [colId, agg]) => {
4733
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(colId);
4734
+ if ((adaptableAggFunc === null || adaptableAggFunc === void 0 ? void 0 : adaptableAggFunc.type) === 'weightedAverage' && agg === AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME) {
4735
+ // do not override the agg func
4736
+ acc[colId] = currentLayout.AggregationColumns[colId];
4737
+ }
4738
+ else {
4739
+ acc[colId] = agg;
4740
+ }
4741
+ return acc;
4742
+ }, {});
4743
+ }
4628
4744
  }
4629
4745
  exports.Adaptable = Adaptable;
4630
4746
  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
+ };