@adaptabletools/adaptable 12.1.5 → 12.1.8-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 (214) 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 +12 -4
  8. package/src/AdaptableOptions/ColumnOptions.d.ts +2 -4
  9. package/src/AdaptableOptions/FilterOptions.d.ts +19 -0
  10. package/src/AdaptableOptions/FinancePluginOptions.d.ts +22 -1
  11. package/src/AdaptableOptions/StateOptions.d.ts +25 -12
  12. package/src/AdaptableOptions/UserInterfaceOptions.d.ts +31 -24
  13. package/src/Api/ColumnApi.d.ts +6 -1
  14. package/src/Api/ExportApi.d.ts +5 -0
  15. package/src/Api/FilterApi.d.ts +29 -0
  16. package/src/Api/FlashingCellApi.d.ts +8 -0
  17. package/src/Api/GridApi.d.ts +1 -0
  18. package/src/Api/Implementation/ColumnApiImpl.d.ts +2 -1
  19. package/src/Api/Implementation/ColumnApiImpl.js +7 -2
  20. package/src/Api/Implementation/DataSetApiImpl.js +1 -1
  21. package/src/Api/Implementation/ExportApiImpl.d.ts +3 -1
  22. package/src/Api/Implementation/ExportApiImpl.js +19 -3
  23. package/src/Api/Implementation/FilterApiImpl.d.ts +6 -0
  24. package/src/Api/Implementation/FilterApiImpl.js +42 -4
  25. package/src/Api/Implementation/FlashingCellApiImpl.d.ts +1 -0
  26. package/src/Api/Implementation/FlashingCellApiImpl.js +4 -0
  27. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  28. package/src/Api/Implementation/GridApiImpl.js +4 -4
  29. package/src/Api/Implementation/InternalApiImpl.d.ts +0 -1
  30. package/src/Api/Implementation/InternalApiImpl.js +0 -3
  31. package/src/Api/Implementation/LayoutApiImpl.d.ts +1 -1
  32. package/src/Api/Implementation/LayoutApiImpl.js +4 -3
  33. package/src/Api/Implementation/PredicateApiImpl.js +4 -0
  34. package/src/Api/Implementation/QueryApiImpl.js +1 -1
  35. package/src/Api/Implementation/QueryLanguageApiImpl.js +9 -1
  36. package/src/Api/Implementation/TeamSharingApiImpl.js +1 -1
  37. package/src/Api/InternalApi.d.ts +0 -1
  38. package/src/Api/LayoutApi.d.ts +1 -1
  39. package/src/Api/SystemStatusApi.d.ts +1 -1
  40. package/src/Api/ToolPanelApi.d.ts +1 -1
  41. package/src/PredefinedConfig/CalculatedColumnState.d.ts +2 -2
  42. package/src/PredefinedConfig/Common/AdaptableColumn.js +3 -2
  43. package/src/PredefinedConfig/Common/AdaptablePredicate.js +30 -10
  44. package/src/PredefinedConfig/Common/AdaptableQuery.js +1 -1
  45. package/src/PredefinedConfig/Common/AggregationColumns.d.ts +6 -0
  46. package/src/PredefinedConfig/Common/AggregationColumns.js +4 -0
  47. package/src/PredefinedConfig/Common/ColumnFilter.d.ts +2 -2
  48. package/src/PredefinedConfig/Common/Enums.d.ts +0 -15
  49. package/src/PredefinedConfig/Common/Enums.js +1 -18
  50. package/src/PredefinedConfig/Common/SpecialColumnSettings.d.ts +6 -6
  51. package/src/PredefinedConfig/ExportState.d.ts +12 -4
  52. package/src/PredefinedConfig/LayoutState.d.ts +2 -1
  53. package/src/PredefinedConfig/PopupState.d.ts +1 -2
  54. package/src/Redux/ActionsReducers/AlertRedux.d.ts +1 -1
  55. package/src/Redux/ActionsReducers/AlertRedux.js +1 -1
  56. package/src/Redux/ActionsReducers/ConditionalStyleRedux.d.ts +1 -1
  57. package/src/Redux/ActionsReducers/ConditionalStyleRedux.js +1 -1
  58. package/src/Redux/ActionsReducers/CustomSortRedux.d.ts +1 -1
  59. package/src/Redux/ActionsReducers/CustomSortRedux.js +1 -1
  60. package/src/Redux/ActionsReducers/FlashingCellRedux.d.ts +1 -1
  61. package/src/Redux/ActionsReducers/FlashingCellRedux.js +1 -1
  62. package/src/Redux/ActionsReducers/FormatColumnRedux.d.ts +1 -1
  63. package/src/Redux/ActionsReducers/FormatColumnRedux.js +1 -1
  64. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +28 -0
  65. package/src/Redux/ActionsReducers/LayoutRedux.js +80 -2
  66. package/src/Redux/ActionsReducers/PlusMinusRedux.d.ts +1 -1
  67. package/src/Redux/ActionsReducers/PlusMinusRedux.js +1 -1
  68. package/src/Redux/ActionsReducers/PopupRedux.d.ts +0 -2
  69. package/src/Redux/ActionsReducers/PopupRedux.js +1 -28
  70. package/src/Redux/ActionsReducers/ScheduleRedux.d.ts +5 -5
  71. package/src/Redux/ActionsReducers/ScheduleRedux.js +5 -5
  72. package/src/Redux/ActionsReducers/ShortcutRedux.d.ts +1 -1
  73. package/src/Redux/ActionsReducers/ShortcutRedux.js +1 -1
  74. package/src/Redux/ActionsReducers/SystemRedux.d.ts +1 -2
  75. package/src/Redux/ActionsReducers/SystemRedux.js +1 -2
  76. package/src/Redux/Store/AdaptableStore.js +30 -16
  77. package/src/Strategy/AlertModule.d.ts +1 -0
  78. package/src/Strategy/AlertModule.js +20 -0
  79. package/src/Strategy/CalculatedColumnModule.js +2 -2
  80. package/src/Strategy/ExportModule.d.ts +0 -1
  81. package/src/Strategy/ExportModule.js +0 -16
  82. package/src/Strategy/FilterModule.js +6 -0
  83. package/src/Strategy/FlashingCellModule.js +2 -2
  84. package/src/Strategy/Interface/IModule.d.ts +4 -0
  85. package/src/Strategy/LayoutModule.js +20 -20
  86. package/src/Strategy/Utilities/FormatColumn/getFormatColumnStyleViewItems.js +16 -1
  87. package/src/Strategy/Utilities/Layout/getLayoutFilterViewItems.js +15 -11
  88. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +1 -0
  89. package/src/Utilities/Constants/DocumentationLinkConstants.js +2 -1
  90. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +3 -0
  91. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.d.ts +12 -2
  92. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.js +30 -66
  93. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +22 -6
  94. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +423 -220
  95. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +7 -1
  96. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +23 -7
  97. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +0 -1
  98. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +6 -54
  99. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +17 -5
  100. package/src/Utilities/Extensions/ArrayExtensions.js +6 -0
  101. package/src/Utilities/Helpers/CalendarHelper.js +10 -7
  102. package/src/Utilities/Helpers/DateHelper.d.ts +0 -26
  103. package/src/Utilities/Helpers/DateHelper.js +2 -32
  104. package/src/Utilities/Interface/MessagePopups.d.ts +0 -4
  105. package/src/Utilities/ObjectFactory.d.ts +6 -4
  106. package/src/Utilities/ObjectFactory.js +30 -17
  107. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +25 -0
  108. package/src/Utilities/Services/AggregatedScalarLiveValue.js +103 -0
  109. package/src/Utilities/Services/AlertService.d.ts +0 -1
  110. package/src/Utilities/Services/AlertService.js +5 -17
  111. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +4 -4
  112. package/src/Utilities/Services/CalculatedColumnExpressionService.js +29 -154
  113. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +2 -2
  114. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +6 -3
  115. package/src/Utilities/Services/QueryLanguageService.d.ts +6 -3
  116. package/src/Utilities/Services/QueryLanguageService.js +23 -6
  117. package/src/Utilities/Services/ReportService.js +47 -46
  118. package/src/View/AdaptableView.js +1 -2
  119. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingsTags.d.ts +2 -0
  120. package/src/View/CalculatedColumn/Utilities/{getCalculatedColumnSettingTags.js → getCalculatedColumnSettingsTags.js} +5 -3
  121. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.d.ts +10 -0
  122. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.js +80 -0
  123. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +21 -15
  124. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.d.ts +1 -2
  125. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +10 -53
  126. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +14 -3
  127. package/src/View/Components/AdaptableDateInput/index.js +1 -1
  128. package/src/View/Components/AdaptableObjectList/AdaptableObjectCompactList.js +42 -6
  129. package/src/View/Components/AdaptableObjectList/AdaptableObjectList.js +1 -1
  130. package/src/View/Components/EntityRulesEditor/index.js +26 -5
  131. package/src/View/Components/FilterForm/FilterForm.js +10 -5
  132. package/src/View/Components/FilterForm/ListBoxFilterForm.js +1 -0
  133. package/src/View/Components/FilterForm/QuickFilterForm.js +12 -7
  134. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.d.ts +9 -0
  135. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.js +28 -0
  136. package/src/View/Components/PermittedValuesSelector/index.d.ts +1 -0
  137. package/src/View/Components/PermittedValuesSelector/index.js +5 -0
  138. package/src/View/Components/Popups/AdaptablePopup/Navigation.js +2 -2
  139. package/src/View/Components/Popups/AdaptableToaster.js +2 -7
  140. package/src/View/Components/Popups/WindowPopups/windowFactory.d.ts +0 -1
  141. package/src/View/Components/Popups/WindowPopups/windowFactory.js +1 -4
  142. package/src/View/Export/ExportViewPanel.d.ts +1 -2
  143. package/src/View/Export/ExportViewPanel.js +2 -6
  144. package/src/View/Export/Wizard/ReportColumnTypeWizard.d.ts +1 -2
  145. package/src/View/Export/Wizard/ReportColumnTypeWizard.js +11 -12
  146. package/src/View/Export/Wizard/ReportRowTypeWizard.d.ts +1 -2
  147. package/src/View/Export/Wizard/ReportRowTypeWizard.js +12 -13
  148. package/src/View/Export/Wizard/ReportSettingsWizard.js +1 -2
  149. package/src/View/Filter/FilterViewPanel.js +20 -4
  150. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  151. package/src/View/FreeTextColumn/FreeTextColumnSummary.js +1 -2
  152. package/src/View/FreeTextColumn/Wizard/FreeTextColumnSettingsWizardSection.d.ts +1 -1
  153. package/src/View/FreeTextColumn/Wizard/FreeTextColumnWizard.js +1 -1
  154. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.d.ts +0 -0
  155. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.js +0 -0
  156. package/src/View/Layout/Wizard/LayoutWizard.js +1 -0
  157. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +1 -0
  158. package/src/View/Layout/Wizard/sections/AggregationsSection.js +69 -8
  159. package/src/View/Layout/Wizard/sections/ColumnsSection.js +1 -1
  160. package/src/View/Query/QueryViewPanel.js +1 -1
  161. package/src/agGrid/Adaptable.d.ts +12 -3
  162. package/src/agGrid/Adaptable.js +225 -152
  163. package/src/agGrid/agGridHelper.d.ts +1 -0
  164. package/src/agGrid/agGridHelper.js +5 -3
  165. package/src/agGrid/agGridMenuHelper.d.ts +1 -0
  166. package/src/agGrid/agGridMenuHelper.js +4 -2
  167. package/src/agGrid/weightedAverage.d.ts +6 -0
  168. package/src/agGrid/weightedAverage.js +66 -0
  169. package/src/components/ExpressionEditor/BaseEditorInput.d.ts +1 -0
  170. package/src/components/ExpressionEditor/BaseEditorInput.js +2 -3
  171. package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
  172. package/src/components/ExpressionEditor/EditorInput.js +24 -4
  173. package/src/components/ExpressionEditor/{EditorInputReactive.d.ts → EditorInputWithWhereClause.d.ts} +3 -3
  174. package/src/components/ExpressionEditor/{EditorInputReactive.js → EditorInputWithWhereClause.js} +6 -5
  175. package/src/components/ExpressionEditor/editorButtonsAggregatedBoolean.d.ts +2 -0
  176. package/src/components/ExpressionEditor/{editorButtonsReactive.js → editorButtonsAggregatedBoolean.js} +22 -37
  177. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +5 -10
  178. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.d.ts +2 -0
  179. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.js +50 -0
  180. package/src/components/ExpressionEditor/editorButtonsObservable.d.ts +2 -0
  181. package/src/components/ExpressionEditor/editorButtonsObservable.js +40 -0
  182. package/src/components/ExpressionEditor/index.d.ts +1 -1
  183. package/src/components/ExpressionEditor/index.js +26 -5
  184. package/src/components/ProgressIndicator/ProgressIndicator.js +10 -12
  185. package/src/metamodel/adaptable.metamodel.d.ts +129 -7
  186. package/src/metamodel/adaptable.metamodel.js +1 -1
  187. package/src/parser/src/types.d.ts +1 -1
  188. package/src/types.d.ts +4 -4
  189. package/version.d.ts +1 -1
  190. package/version.js +1 -1
  191. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingTags.d.ts +0 -2
  192. package/src/View/Layout/LayoutEditorStandalonePopup.d.ts +0 -3
  193. package/src/View/Layout/LayoutEditorStandalonePopup.js +0 -78
  194. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.d.ts +0 -27
  195. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.js +0 -86
  196. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.d.ts +0 -16
  197. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.js +0 -89
  198. package/src/View/Layout/Wizard/LayoutEditor/PivotList.d.ts +0 -15
  199. package/src/View/Layout/Wizard/LayoutEditor/PivotList.js +0 -70
  200. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.d.ts +0 -15
  201. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.js +0 -70
  202. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.d.ts +0 -7
  203. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.js +0 -11
  204. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.d.ts +0 -6
  205. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.js +0 -26
  206. package/src/View/Layout/Wizard/LayoutEditor/index.d.ts +0 -9
  207. package/src/View/Layout/Wizard/LayoutEditor/index.js +0 -367
  208. package/src/View/Layout/Wizard/LayoutEditor/reducer.d.ts +0 -28
  209. package/src/View/Layout/Wizard/LayoutEditor/reducer.js +0 -46
  210. package/src/View/Layout/Wizard/LayoutEditor/utils.d.ts +0 -10
  211. package/src/View/Layout/Wizard/LayoutEditor/utils.js +0 -14
  212. package/src/View/Layout/Wizard/LayoutEditorWizard.d.ts +0 -30
  213. package/src/View/Layout/Wizard/LayoutEditorWizard.js +0 -132
  214. 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 = '/';
@@ -266,6 +268,9 @@ class Adaptable {
266
268
  };
267
269
  // (global as any).adaptable = this;
268
270
  }
271
+ get isLive() {
272
+ return this.isInitialised && !this.isDestroyed;
273
+ }
269
274
  static init(adaptableOptions) {
270
275
  return Adaptable.initInternal(adaptableOptions);
271
276
  }
@@ -362,6 +367,7 @@ class Adaptable {
362
367
  this.isInitialised = false;
363
368
  this.useRowNodeLookUp = false; // we will set later in instantiate if possible to be true
364
369
  this.forPlugins((plugin) => plugin.afterInitOptions(this, this.adaptableOptions));
370
+ this.registerAdaptableAggFuncs(adaptableOptions);
365
371
  // get the api ready
366
372
  this.api = new AdaptableApiImpl_1.AdaptableApiImpl(this);
367
373
  this.forPlugins((plugin) => plugin.afterInitApi(this, this.api));
@@ -372,10 +378,13 @@ class Adaptable {
372
378
  this.agGridMenuHelper = new agGridMenuHelper_1.agGridMenuHelper(this, this.gridOptions);
373
379
  // Build the default group sort comparator - will get custom sort values (but not functions) in real time
374
380
  // TODO: if a custom 'aggFunc' property is defined (see setupColumnAggFunc()), it won't be evaluated
375
- if (!this.getInitialGroupOrderComparator(this.gridOptions) &&
376
- this.adaptableOptions.columnOptions.autoOrderGroupedColumns) {
377
- this.gridOptions.initialGroupOrderComparator =
378
- 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
+ });
379
388
  }
380
389
  // we prefer the grid to be NOT instantiated so that we can do it
381
390
  // perhaps in future we will force instantiation only?
@@ -542,7 +551,7 @@ class Adaptable {
542
551
  });
543
552
  }
544
553
  performAudit(action, oldState, newState) {
545
- if (this.isInitialised) {
554
+ if (this.isLive) {
546
555
  const adaptableStateChangedInfo = {
547
556
  adaptableApi: this.api,
548
557
  actionName: action.type,
@@ -568,15 +577,6 @@ class Adaptable {
568
577
  }
569
578
  if ((_a = this.adaptableOptions.generalOptions) === null || _a === void 0 ? void 0 : _a.hideEmptyGroupRows) {
570
579
  LoggingHelper_1.ConsoleLogWarning(`DEPRECATED: 'GeneralOptions.hideEmptyGroupRows' is deprecated and will no longer be evaluated!`);
571
- // disabled due to showstopper starting with AG Grid v26
572
- // the internal implementation of AG Grids GroupCellRenderer has changed A LOT!
573
- // this.gridOptions.components = this.gridOptions.components || {};
574
- //
575
- // this.gridOptions.autoGroupColumnDef = this.gridOptions.autoGroupColumnDef || {};
576
- // if (!this.gridOptions.autoGroupColumnDef.cellRenderer) {
577
- // this.gridOptions.autoGroupColumnDef.cellRenderer = '__adaptableGroupCellRenderer';
578
- // this.gridOptions.components.__adaptableGroupCellRenderer = AdaptableGroupCellRenderer;
579
- // }
580
580
  }
581
581
  const adaptableSideBarDef = this.createAdaptableSideBarDef();
582
582
  if (!!adaptableSideBarDef) {
@@ -584,12 +584,9 @@ class Adaptable {
584
584
  this.gridOptions.components.AdaptableToolPanel = AdaptableToolPanel_1.getAdaptableToolPanelAgGridComponent(this);
585
585
  }
586
586
  if (this.agGridHelper.isSideBarDefObject(adaptableSideBarDef)) {
587
- if (this.gridOptions.api) {
588
- this.gridOptions.api.setSideBar(adaptableSideBarDef);
589
- }
590
- else {
591
- this.gridOptions.sideBar = adaptableSideBarDef;
592
- }
587
+ this.setGridOptionsProperty('sideBar', () => {
588
+ return adaptableSideBarDef;
589
+ });
593
590
  this.hasAdaptableToolPanel = true;
594
591
  }
595
592
  this.createStatusBars();
@@ -717,24 +714,25 @@ class Adaptable {
717
714
  }
718
715
  }
719
716
  createStatusBars() {
720
- var _a, _b;
721
- const statusBarOptions = Object.assign({}, this.gridOptions.statusBar);
722
717
  const adaptableStatusPanelKeys = [];
723
- 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) => {
724
- if (statusPanel.statusPanel === StatusBarState_1.ADAPTABLE_STATUS_PANEL) {
725
- adaptableStatusPanelKeys.push(statusPanel.key);
726
- const context = {
727
- Key: statusPanel.key,
728
- };
729
- return Object.assign(Object.assign({}, statusPanel), { statusPanel: createAgStatusPanelComponent_1.createAgStatusPanelComponent(AdaptableStatusBar_1.AdaptableStatusBar, this, context) });
730
- }
731
- 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 });
732
731
  });
733
- statusBarOptions.statusPanels = statusPanels;
734
- this.gridOptions.statusBar = statusBarOptions;
735
732
  const statusBarModule = this.ModuleService.getModuleById(ModuleConstants.StatusBarModuleId);
736
733
  this.api.eventApi.on('AdaptableReady', () => {
737
- 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));
738
736
  // need to add only the adaptable panels
739
737
  statusBarModule.syncStateWithOptions(adaptableStatusPanels);
740
738
  });
@@ -1328,15 +1326,25 @@ class Adaptable {
1328
1326
  newColState.aggFunc = null;
1329
1327
  if (aggregationFunctionsColumnsMap[colId] != null) {
1330
1328
  const colDef = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.getColumnDef(colId);
1331
- newColState.aggFunc =
1332
- aggregationFunctionsColumnsMap[colId] === 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
- (_e = (_d = (_c = colState.aggFunc) !== null && _c !== void 0 ? _c : colDef === null || colDef === void 0 ? void 0 : colDef.aggFunc) !== null && _d !== void 0 ? _d :
1337
- // @ts-ignore available only wth ag-Grid v27.3.x
1338
- colDef === null || colDef === void 0 ? void 0 : colDef.defaultAggFunc) !== null && _e !== void 0 ? _e : 'sum'
1339
- : 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;
1340
1348
  }
1341
1349
  if (sortModelMap[colId]) {
1342
1350
  newColState.sort = sortModelMap[colId].sort;
@@ -1521,7 +1529,8 @@ class Adaptable {
1521
1529
  layout.ColumnSorts = columnSorts;
1522
1530
  layout.RowGroupedColumns = groupedColumns;
1523
1531
  if (Object.keys(aggregatedColumns).length) {
1524
- layout.AggregationColumns = aggregatedColumns;
1532
+ // ag-grid aggregations are not 1-1 with adaptable column-aggregations
1533
+ layout.AggregationColumns = this.handleUpdateWeightedAvgFromGrid(aggregatedColumns);
1525
1534
  }
1526
1535
  layout.EnablePivot = this.gridOptions.columnApi.isPivotMode();
1527
1536
  layout.PivotColumns = pivotColumns;
@@ -1720,7 +1729,7 @@ class Adaptable {
1720
1729
  const filterPermittedValuesParams = {
1721
1730
  adaptableApi: this.api,
1722
1731
  column: column,
1723
- filter: filter,
1732
+ searchFilter: filter,
1724
1733
  };
1725
1734
  preparedPermittedValues = await (permittedValues === null || permittedValues === void 0 ? void 0 : permittedValues.values(filterPermittedValuesParams));
1726
1735
  }
@@ -1945,7 +1954,10 @@ class Adaptable {
1945
1954
  return typeof rawValue !== 'string' ? String(rawValue) : rawValue;
1946
1955
  }
1947
1956
  if (dataType === 'Number') {
1948
- 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;
1949
1961
  }
1950
1962
  if (dataType === 'Boolean') {
1951
1963
  return typeof rawValue !== 'boolean' ? Boolean(rawValue) : rawValue;
@@ -2022,7 +2034,9 @@ class Adaptable {
2022
2034
  getAllRowNodes(config) {
2023
2035
  let rowNodes = [];
2024
2036
  this.gridOptions.api.forEachNode((rowNode, rowIndex) => {
2025
- 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) {
2026
2040
  rowNodes.push(rowNode);
2027
2041
  }
2028
2042
  });
@@ -2077,6 +2091,9 @@ class Adaptable {
2077
2091
  this.gridOptions.api.redrawRows();
2078
2092
  this._emit('GridRefreshed');
2079
2093
  }
2094
+ redrawRenderedRows() {
2095
+ this.redrawRows(this.gridOptions.api.getRenderedNodes());
2096
+ }
2080
2097
  redrawHeader() {
2081
2098
  this.gridOptions.api.refreshHeader();
2082
2099
  }
@@ -2127,8 +2144,7 @@ class Adaptable {
2127
2144
  ];
2128
2145
  }
2129
2146
  getColDefsForFreeTextColumns() {
2130
- const specialColumnsAreFilterable = this.api.internalApi.getAdaptableOptions().filterOptions.enableFilterOnSpecialColumns;
2131
- const defaultFreeTextColumnSettings = ObjectFactory_1.CreateEmptyFreeTextColumn(specialColumnsAreFilterable).FreeTextColumnSettings;
2147
+ const defaultFreeTextColumnSettings = ObjectFactory_1.CreateEmptyFreeTextColumn().FreeTextColumnSettings;
2132
2148
  return this.api.freeTextColumnApi.getAllFreeTextColumn().map((freeTextColumn) => {
2133
2149
  var _a;
2134
2150
  const freeTextColumnSettings = Object.assign(Object.assign({}, defaultFreeTextColumnSettings), freeTextColumn.FreeTextColumnSettings);
@@ -2178,10 +2194,31 @@ class Adaptable {
2178
2194
  return newColDef;
2179
2195
  });
2180
2196
  }
2181
- setupColumnValueGetter({ col }) {
2182
- // need this here if we want plugins to intercept
2197
+ setupColumnValueGetter({ col, abColumn }) {
2183
2198
  this.setColDefProperty(col, 'valueGetter', (userValue) => {
2184
- 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
+ };
2185
2222
  });
2186
2223
  }
2187
2224
  setupColumnAggFunc({ col }) {
@@ -2369,45 +2406,8 @@ class Adaptable {
2369
2406
  this.safeSetColDefs(resultColDefs);
2370
2407
  this.setLayout();
2371
2408
  }
2372
- cleanupFloatingFilters_WORKAROUND() {
2373
- // since AG Grid v26.2.0 floating filters have a memory leak due to an dangling reference to an obsolete agSetFilter instance
2374
- var _a, _b;
2375
- // 1a. The initial floating filter component is defaulted to the 'agSetColumnFloatingFilter'
2376
- // (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.
2377
- // 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
2378
- // 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
2379
- // 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
2380
- // 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
2381
- //
2382
- // 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
2383
- // AG Grid team tracks this issue in AG-6179
2384
- // until a fix arrives, a workaround is to hide all the visible columns (thus destroying all the HeaderFilterCellCtrl instances)
2385
- if (!((_b = (_a = this.adaptableOptions) === null || _a === void 0 ? void 0 : _a.filterOptions) === null || _b === void 0 ? void 0 : _b.useAdaptableQuickFilter)) {
2386
- // no need to do anything if we don't use adaptable quick filter
2387
- return;
2388
- }
2389
- if (this.gridOptions.columnApi.isPivotMode()) {
2390
- // floating filters are NOT available in pivot mode
2391
- return;
2392
- }
2393
- // floating filter instances (HeaderFilterCellCtrl) are created only for rendered columns (in viewport)
2394
- // so we have to handle only the displayed columns
2395
- const allDisplayedCols = this.gridOptions.columnApi.getAllDisplayedColumns();
2396
- const colsWithFloatingFilter = allDisplayedCols.filter((col) => {
2397
- const colDef = col.getColDef();
2398
- return (colDef.floatingFilter ||
2399
- colDef.floatingFilterComponent ||
2400
- this.api.columnApi.usesAdaptableQuickFilter(col.getColId()));
2401
- });
2402
- colsWithFloatingFilter.forEach((col) => this.gridOptions.columnApi.setColumnsVisible(colsWithFloatingFilter, false));
2403
- // !! it is important to NOT set the columns visible again as this is already taken care of in the next performed method (this.updateColDefsForSpecialColumns())
2404
- }
2405
2409
  getColDefsForCalculatedColumns() {
2406
- const specialColumnsAreFilterable = this.adaptableOptions.filterOptions
2407
- .enableFilterOnSpecialColumns
2408
- ? this.adaptableOptions.filterOptions.enableFilterOnSpecialColumns
2409
- : true;
2410
- const defaultCalculatedColumnSettings = ObjectFactory_1.CreateEmptyCalculatedColumn(specialColumnsAreFilterable).CalculatedColumnSettings;
2410
+ const defaultCalculatedColumnSettings = ObjectFactory_1.CreateEmptyCalculatedColumn().CalculatedColumnSettings;
2411
2411
  const isExternalEvaluation = !this.api.internalApi.runModuleInAdaptableQL('CalculatedColumn');
2412
2412
  return this.api.calculatedColumnApi.getAllCalculatedColumn().map((calculatedColumn) => {
2413
2413
  const calculatedColumnSettings = Object.assign(Object.assign({}, defaultCalculatedColumnSettings), calculatedColumn.CalculatedColumnSettings);
@@ -2536,7 +2536,22 @@ class Adaptable {
2536
2536
  this.throttleFilterOnTickingDataChange = null;
2537
2537
  this.gridOptions.api.__adaptable = null;
2538
2538
  this.gridOptions.api.setColumnDefs = GridApi_setColumnDefs;
2539
- 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
+ ]);
2552
+ if (this.gridOptions.components) {
2553
+ this.gridOptions.components.AdaptableToolPanel = null;
2554
+ }
2540
2555
  if (config && config.destroyApi === false) {
2541
2556
  }
2542
2557
  else {
@@ -2556,6 +2571,8 @@ class Adaptable {
2556
2571
  this.emitter.destroy();
2557
2572
  this.emitter = null;
2558
2573
  this._adaptableReady = false;
2574
+ this.agGridHelper.destroy();
2575
+ this.agGridMenuHelper.destroy();
2559
2576
  Adaptable.dismissInstance(this);
2560
2577
  const abContainerElement = this.getAdaptableContainerElement();
2561
2578
  if (config && !config.unmount) {
@@ -2890,74 +2907,76 @@ class Adaptable {
2890
2907
  },
2891
2908
  };
2892
2909
  // We plug our filter mechanism and if there is already something like external widgets... we save ref to the function
2893
- const original_isExternalFilterPresent = this.gridOptions.isExternalFilterPresent;
2894
- this.gridOptions.isExternalFilterPresent = (params) => {
2895
- if (this.isDestroyed) {
2896
- return true;
2897
- }
2898
- const columnFilters = this.api.filterApi.getColumnFilters();
2899
- const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2900
- const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2901
- return (isFilterActive ||
2902
- isQueryActive ||
2903
- // it means that originaldoesExternalFilterPass will be called so we reinit that collection
2904
- (original_isExternalFilterPresent ? original_isExternalFilterPresent(params) : false));
2905
- };
2906
- const originaldoesExternalFilterPass = this.gridOptions.doesExternalFilterPass;
2910
+ this.setGridOptionsProperty('isExternalFilterPresent', (originalIsExternalFilterPresent) => {
2911
+ return (params) => {
2912
+ if (this.isDestroyed) {
2913
+ return true;
2914
+ }
2915
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2916
+ const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(columnFilters);
2917
+ const isQueryActive = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(this.api.queryApi.getCurrentQuery());
2918
+ return (isFilterActive ||
2919
+ isQueryActive ||
2920
+ // it means that originalIsExternalFilterPresent will be called so we reinit that collection
2921
+ (originalIsExternalFilterPresent ? originalIsExternalFilterPresent(params) : false));
2922
+ };
2923
+ });
2907
2924
  const evaluateQueryOnClient = this.api.internalApi.runModuleInAdaptableQL('Query');
2908
2925
  const evaluateFilterOnClient = this.api.internalApi.runModuleInAdaptableQL('Filter');
2909
- this.gridOptions.doesExternalFilterPass = (node) => {
2910
- if (this.isDestroyed) {
2911
- return true;
2912
- }
2913
- // first we assess Query (if its running locally)
2914
- if (evaluateQueryOnClient && !this.isGroupRowNode(node)) {
2915
- const currentQuery = this.api.queryApi.getCurrentQuery();
2916
- if (currentQuery) {
2917
- const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2918
- if (!isCurrentQueryValid ||
2919
- !this.api.internalApi
2920
- .getQueryLanguageService()
2921
- .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2922
- return false;
2926
+ this.setGridOptionsProperty('doesExternalFilterPass', (originalDoesExternalFilterPass) => {
2927
+ return (node) => {
2928
+ if (this.isDestroyed) {
2929
+ return true;
2930
+ }
2931
+ // first we assess Query (if its running locally)
2932
+ if (evaluateQueryOnClient && !this.isGroupRowNode(node)) {
2933
+ const currentQuery = this.api.queryApi.getCurrentQuery();
2934
+ if (currentQuery) {
2935
+ const isCurrentQueryValid = this.api.queryLanguageApi.isValidBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, `Invalid CurrentQuery '${currentQuery}'`);
2936
+ if (!isCurrentQueryValid ||
2937
+ !this.api.internalApi
2938
+ .getQueryLanguageService()
2939
+ .evaluateBooleanExpression(currentQuery, ModuleConstants_1.QueryModuleId, node)) {
2940
+ return false;
2941
+ }
2923
2942
  }
2924
2943
  }
2925
- }
2926
- try {
2927
- // we then assess filters (if running locally)
2928
- if (evaluateFilterOnClient) {
2929
- const columnFilters = this.api.filterApi.getColumnFilters();
2930
- if (columnFilters.length > 0) {
2931
- for (const columnFilter of columnFilters) {
2932
- if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2933
- return false;
2944
+ try {
2945
+ // we then assess filters (if running locally)
2946
+ if (evaluateFilterOnClient) {
2947
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2948
+ if (columnFilters.length > 0) {
2949
+ for (const columnFilter of columnFilters) {
2950
+ if (!this.api.filterApi.evaluateColumnFilter(columnFilter, node)) {
2951
+ return false;
2952
+ }
2934
2953
  }
2935
2954
  }
2936
2955
  }
2937
2956
  }
2938
- }
2939
- catch (ex) {
2940
- LoggingHelper_1.LogAdaptableError(ex);
2941
- return false;
2942
- }
2943
- return originaldoesExternalFilterPass ? originaldoesExternalFilterPass(node) : true;
2944
- };
2945
- // Build the COLUMN MENU. Note that we do this EACH time the menu is opened (as items can change)
2946
- const originalgetMainMenuItems = this.gridOptions.getMainMenuItems;
2947
- this.gridOptions.getMainMenuItems = (params) => {
2948
- // 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....
2949
- return this.agGridMenuHelper.buildColumnMenu(params, originalgetMainMenuItems);
2950
- };
2951
- // Build the CONTEXT MENU. Again we do this each time a cell is right clicked as its context-sensitive
2952
- const originalgetContextMenuItems = this.gridOptions.getContextMenuItems;
2953
- this.gridOptions.getContextMenuItems = (params) => {
2954
- return this.agGridMenuHelper.buildContextMenu(params, originalgetContextMenuItems);
2955
- };
2957
+ catch (ex) {
2958
+ LoggingHelper_1.LogAdaptableError(ex);
2959
+ return false;
2960
+ }
2961
+ return originalDoesExternalFilterPass ? originalDoesExternalFilterPass(node) : true;
2962
+ };
2963
+ });
2964
+ this.setGridOptionsProperty('getMainMenuItems', (userPropertyValue) => {
2965
+ return (params) => {
2966
+ // 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....
2967
+ return this.agGridMenuHelper.buildColumnMenu(params, userPropertyValue);
2968
+ };
2969
+ });
2970
+ this.setGridOptionsProperty('getContextMenuItems', (userPropertyValue) => {
2971
+ return (params) => {
2972
+ return this.agGridMenuHelper.buildContextMenu(params, userPropertyValue);
2973
+ };
2974
+ });
2956
2975
  this.prepareGrid();
2957
2976
  }
2958
2977
  updateColumnFilterActiveState() {
2959
2978
  var _a;
2960
- const columnFilters = this.api.filterApi.getColumnFilters();
2979
+ const columnFilters = this.api.filterApi.getActiveColumnFilters();
2961
2980
  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));
2962
2981
  const isFilterActive = ArrayExtensions_1.ArrayExtensions.IsNotNullOrEmpty(activeFilters);
2963
2982
  const columnsWithActiveFilters = {};
@@ -3039,6 +3058,7 @@ class Adaptable {
3039
3058
  this.setupColumnCellEditor(colSetupInfo);
3040
3059
  this.setupColumnHeader(colSetupInfo);
3041
3060
  this.setupColumnQuickFilerText(colSetupInfo);
3061
+ this.setupAllowedAggFuncs(colSetupInfo);
3042
3062
  });
3043
3063
  this.setupRowStyling();
3044
3064
  // setupAggregationColumnHeaders() is executed on every setLayout()
@@ -3048,6 +3068,14 @@ class Adaptable {
3048
3068
  this.redrawBody();
3049
3069
  this.redrawHeader();
3050
3070
  }
3071
+ revertGridOptionsPropertiesToUserValue(propertyNames) {
3072
+ for (const propertyName of propertyNames) {
3073
+ // see this.setGridOptionsProperty(...)
3074
+ const userKey = `user.${propertyName}`;
3075
+ const userValue = this.gridOptionsPropertyCache.get(userKey);
3076
+ this.gridOptions[propertyName] = userValue;
3077
+ }
3078
+ }
3051
3079
  setGridOptionsProperty(propertyName, propertyGetter) {
3052
3080
  if (this.isDestroyed) {
3053
3081
  return;
@@ -3286,6 +3314,11 @@ class Adaptable {
3286
3314
  };
3287
3315
  });
3288
3316
  }
3317
+ setupAllowedAggFuncs({ col, abColumn }) {
3318
+ this.setColDefProperty(col, 'allowedAggFuncs', () => {
3319
+ return abColumn.availableAggregationFunctions;
3320
+ });
3321
+ }
3289
3322
  setupColumnHeader({ col, abColumn }) {
3290
3323
  var _a, _b;
3291
3324
  const previousColumnHeader = (_a = col === null || col === void 0 ? void 0 : col.getColDef()) === null || _a === void 0 ? void 0 : _a.headerName;
@@ -3483,11 +3516,6 @@ class Adaptable {
3483
3516
  applyCurrentTheme() {
3484
3517
  this.api.themeApi.applyCurrentTheme();
3485
3518
  }
3486
- getInitialGroupOrderComparator(gridOptions) {
3487
- var _a, _b;
3488
- // fallback to deprecated forms
3489
- return ((_b = (_a = gridOptions.initialGroupOrderComparator) !== null && _a !== void 0 ? _a : gridOptions.defaultGroupOrderComparator) !== null && _b !== void 0 ? _b : gridOptions.defaultGroupSortComparator);
3490
- }
3491
3519
  applyFinalRendering() {
3492
3520
  this.embedColumnMenu = this.isModulePresent('menu');
3493
3521
  if (this.gridOptions.treeData && this.gridOptions.treeData == true) {
@@ -4621,6 +4649,51 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4621
4649
  }
4622
4650
  return this.gridOptions.api.getChartModels();
4623
4651
  }
4652
+ getActiveAdaptableAggFuncForCol(columnId) {
4653
+ if (!columnId) {
4654
+ return null;
4655
+ }
4656
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4657
+ const aggregationFunctionsColumnsMap = currentLayout.AggregationColumns || {};
4658
+ const adaptableAggFunc = aggregationFunctionsColumnsMap[columnId];
4659
+ if (typeof adaptableAggFunc === 'object' &&
4660
+ 'type' in adaptableAggFunc &&
4661
+ adaptableAggFunc.type === 'weightedAverage') {
4662
+ return adaptableAggFunc;
4663
+ }
4664
+ return null;
4665
+ }
4666
+ registerAdaptableAggFuncs(adaptableOptions) {
4667
+ adaptableOptions.gridOptions.aggFuncs = this.adaptableOptions.gridOptions.aggFuncs || {};
4668
+ adaptableOptions.gridOptions.aggFuncs[AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME] = (params) => {
4669
+ const columnId = params.column.getColId();
4670
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
4671
+ if (!adaptableAggFunc) {
4672
+ return undefined;
4673
+ }
4674
+ if (adaptableAggFunc.type === 'weightedAverage') {
4675
+ return weightedAverage_1.weightedAverage(params, params.colDef.colId, adaptableAggFunc.weightedColumnId);
4676
+ }
4677
+ return undefined;
4678
+ };
4679
+ }
4680
+ /**
4681
+ * When reading the state from the grid, we have to make sure 'avg' is not overriden with the 'avg' string.
4682
+ */
4683
+ handleUpdateWeightedAvgFromGrid(aggFuncFromGrid) {
4684
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
4685
+ return Object.entries(aggFuncFromGrid).reduce((acc, [colId, agg]) => {
4686
+ const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(colId);
4687
+ if ((adaptableAggFunc === null || adaptableAggFunc === void 0 ? void 0 : adaptableAggFunc.type) === 'weightedAverage' && agg === AggregationColumns_1.WEIGHTED_AVERAGE_AGG_FN_NAME) {
4688
+ // do not override the agg func
4689
+ acc[colId] = currentLayout.AggregationColumns[colId];
4690
+ }
4691
+ else {
4692
+ acc[colId] = agg;
4693
+ }
4694
+ return acc;
4695
+ }, {});
4696
+ }
4624
4697
  }
4625
4698
  exports.Adaptable = Adaptable;
4626
4699
  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
+ };