@adaptabletools/adaptable 18.0.0-canary.1 → 18.0.0-canary.11

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 (264) hide show
  1. package/agGrid.d.ts +4 -21
  2. package/agGrid.js +9 -26
  3. package/base.css +11 -3
  4. package/base.css.map +1 -1
  5. package/index.css +88 -70
  6. package/index.css.map +1 -1
  7. package/package.json +4 -5
  8. package/src/AdaptableInterfaces/IAdaptable.d.ts +61 -108
  9. package/src/AdaptableOptions/AdaptableOptions.d.ts +12 -6
  10. package/src/AdaptableOptions/ColumnFilterOptions.d.ts +4 -4
  11. package/src/AdaptableOptions/ColumnOptions.d.ts +4 -2
  12. package/src/AdaptableOptions/{CommentsOptions.d.ts → CommentOptions.d.ts} +5 -5
  13. package/src/AdaptableOptions/MenuOptions.d.ts +1 -1
  14. package/src/AdaptableOptions/MenuOptions.js +1 -5
  15. package/src/AdaptableOptions/{NotesOptions.d.ts → NoteOptions.d.ts} +1 -1
  16. package/src/AdaptableOptions/UserInterfaceOptions.d.ts +17 -0
  17. package/src/Api/AdaptableApi.d.ts +5 -0
  18. package/src/Api/BulkUpdateApi.d.ts +0 -5
  19. package/src/Api/ConfigApi.d.ts +1 -1
  20. package/src/Api/Events/AdaptableReady.d.ts +3 -3
  21. package/src/Api/Events/GridDataChanged.d.ts +4 -4
  22. package/src/Api/GridApi.d.ts +18 -13
  23. package/src/Api/Implementation/ActionColumnApiImpl.d.ts +2 -0
  24. package/src/Api/Implementation/ActionColumnApiImpl.js +33 -0
  25. package/src/Api/Implementation/AdaptableApiImpl.d.ts +1 -0
  26. package/src/Api/Implementation/AdaptableApiImpl.js +3 -0
  27. package/src/Api/Implementation/ApiBase.d.ts +2 -1
  28. package/src/Api/Implementation/ApiBase.js +4 -1
  29. package/src/Api/Implementation/BulkUpdateApiImpl.d.ts +0 -1
  30. package/src/Api/Implementation/BulkUpdateApiImpl.js +0 -4
  31. package/src/Api/Implementation/CommentsApiImpl.d.ts +4 -0
  32. package/src/Api/Implementation/CommentsApiImpl.js +7 -1
  33. package/src/Api/Implementation/ConfigApiImpl.js +13 -5
  34. package/src/Api/Implementation/GridApiImpl.d.ts +4 -3
  35. package/src/Api/Implementation/GridApiImpl.js +33 -14
  36. package/src/Api/Implementation/LayoutApiImpl.d.ts +2 -0
  37. package/src/Api/Implementation/LayoutApiImpl.js +15 -0
  38. package/src/Api/Implementation/NotesApiImpl.d.ts +6 -4
  39. package/src/Api/Implementation/NotesApiImpl.js +9 -8
  40. package/src/Api/Implementation/OptionsApiImpl.d.ts +2 -1
  41. package/src/Api/Implementation/OptionsApiImpl.js +12 -2
  42. package/src/Api/Implementation/ScopeApiImpl.d.ts +2 -0
  43. package/src/Api/Implementation/ScopeApiImpl.js +20 -7
  44. package/src/Api/Implementation/StatusBarApiImpl.d.ts +0 -1
  45. package/src/Api/Implementation/StatusBarApiImpl.js +0 -3
  46. package/src/Api/Implementation/ToolPanelApiImpl.js +6 -6
  47. package/src/Api/Internal/ActionRowInternalApi.d.ts +5 -1
  48. package/src/Api/Internal/ActionRowInternalApi.js +106 -0
  49. package/src/Api/Internal/AdaptableInternalApi.d.ts +3 -4
  50. package/src/Api/Internal/AdaptableInternalApi.js +10 -8
  51. package/src/Api/Internal/CalculatedColumnInternalApi.d.ts +2 -0
  52. package/src/Api/Internal/CalculatedColumnInternalApi.js +70 -0
  53. package/src/Api/Internal/ColumnFilterInternalApi.d.ts +1 -0
  54. package/src/Api/Internal/ColumnFilterInternalApi.js +11 -1
  55. package/src/Api/Internal/ColumnInternalApi.d.ts +4 -1
  56. package/src/Api/Internal/ColumnInternalApi.js +12 -0
  57. package/src/Api/Internal/CommentsInternalApi.d.ts +4 -0
  58. package/src/Api/Internal/CommentsInternalApi.js +14 -0
  59. package/src/Api/Internal/CustomSortInternalApi.d.ts +3 -2
  60. package/src/Api/Internal/CustomSortInternalApi.js +32 -1
  61. package/src/Api/Internal/DataSetInternalApi.js +1 -1
  62. package/src/Api/Internal/FormatColumnInternalApi.js +3 -2
  63. package/src/Api/Internal/FreeTextColumnInternalApi.d.ts +2 -0
  64. package/src/Api/Internal/FreeTextColumnInternalApi.js +59 -0
  65. package/src/Api/Internal/GridFilterInternalApi.js +1 -1
  66. package/src/Api/Internal/GridInternalApi.d.ts +21 -3
  67. package/src/Api/Internal/GridInternalApi.js +126 -7
  68. package/src/Api/Internal/NotesInternalApi.d.ts +4 -0
  69. package/src/Api/Internal/NotesInternalApi.js +14 -0
  70. package/src/Api/Internal/TeamSharingInternalApi.js +1 -1
  71. package/src/Api/InteropioPluginApi.d.ts +2 -2
  72. package/src/Api/LayoutApi.d.ts +11 -0
  73. package/src/Api/OptionsApi.d.ts +5 -1
  74. package/src/Api/ScopeApi.d.ts +10 -0
  75. package/src/EnvVars.d.ts +3 -0
  76. package/src/EnvVars.js +4 -0
  77. package/src/PredefinedConfig/Common/AdaptableColumn.d.ts +4 -0
  78. package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
  79. package/src/PredefinedConfig/Common/AdaptableScope.d.ts +4 -1
  80. package/src/PredefinedConfig/Common/AggregationColumns.d.ts +1 -0
  81. package/src/PredefinedConfig/Common/AggregationColumns.js +3 -0
  82. package/src/PredefinedConfig/Common/DataUpdateConfig.d.ts +8 -0
  83. package/src/PredefinedConfig/Common/RowSummary.d.ts +7 -0
  84. package/src/PredefinedConfig/Common/RowSummary.js +1 -0
  85. package/src/PredefinedConfig/LayoutState.d.ts +5 -0
  86. package/src/PredefinedConfig/NotesState.d.ts +10 -20
  87. package/src/PredefinedConfig/PredefinedConfig.d.ts +1 -1
  88. package/src/PredefinedConfig/SystemState.d.ts +7 -0
  89. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +9 -0
  90. package/src/Redux/ActionsReducers/LayoutRedux.js +20 -0
  91. package/src/Redux/ActionsReducers/NotesRedux.d.ts +3 -4
  92. package/src/Redux/ActionsReducers/NotesRedux.js +8 -7
  93. package/src/Redux/ActionsReducers/SystemRedux.d.ts +5 -0
  94. package/src/Redux/ActionsReducers/SystemRedux.js +13 -1
  95. package/src/Redux/Store/AdaptableStore.d.ts +4 -6
  96. package/src/Redux/Store/AdaptableStore.js +33 -50
  97. package/src/Redux/Store/Interface/IAdaptableStore.d.ts +8 -2
  98. package/src/Strategy/AdaptableModuleBase.d.ts +2 -3
  99. package/src/Strategy/AdaptableModuleBase.js +4 -7
  100. package/src/Strategy/AlertModule.d.ts +1 -2
  101. package/src/Strategy/AlertModule.js +2 -55
  102. package/src/Strategy/CalculatedColumnModule.d.ts +2 -3
  103. package/src/Strategy/CalculatedColumnModule.js +5 -25
  104. package/src/Strategy/CellSummaryModule.d.ts +1 -0
  105. package/src/Strategy/CellSummaryModule.js +50 -21
  106. package/src/Strategy/ChartingModule.d.ts +0 -1
  107. package/src/Strategy/ChartingModule.js +2 -22
  108. package/src/Strategy/ColumnFilterModule.d.ts +1 -2
  109. package/src/Strategy/ColumnFilterModule.js +1 -64
  110. package/src/Strategy/CommentsModule.d.ts +1 -0
  111. package/src/Strategy/CommentsModule.js +5 -1
  112. package/src/Strategy/CustomSortModule.js +1 -1
  113. package/src/Strategy/DashboardModule.d.ts +1 -2
  114. package/src/Strategy/DashboardModule.js +1 -8
  115. package/src/Strategy/DataChangeHistoryModule.d.ts +1 -0
  116. package/src/Strategy/DataChangeHistoryModule.js +3 -1
  117. package/src/Strategy/DataSetModule.d.ts +1 -1
  118. package/src/Strategy/DataSetModule.js +1 -1
  119. package/src/Strategy/FlashingCellModule.d.ts +1 -2
  120. package/src/Strategy/FlashingCellModule.js +2 -15
  121. package/src/Strategy/FormatColumnModule.d.ts +0 -2
  122. package/src/Strategy/FormatColumnModule.js +0 -47
  123. package/src/Strategy/FreeTextColumnModule.d.ts +0 -1
  124. package/src/Strategy/FreeTextColumnModule.js +0 -30
  125. package/src/Strategy/GridFilterModule.d.ts +0 -1
  126. package/src/Strategy/GridFilterModule.js +0 -37
  127. package/src/Strategy/Interface/IModule.d.ts +0 -1
  128. package/src/Strategy/LayoutModule.d.ts +8 -3
  129. package/src/Strategy/LayoutModule.js +108 -53
  130. package/src/Strategy/NamedQueryModule.d.ts +0 -1
  131. package/src/Strategy/NamedQueryModule.js +0 -19
  132. package/src/Strategy/NotesModule.js +3 -4
  133. package/src/Strategy/PlusMinusModule.d.ts +1 -1
  134. package/src/Strategy/PlusMinusModule.js +1 -1
  135. package/src/Strategy/ScheduleModule.d.ts +1 -1
  136. package/src/Strategy/ScheduleModule.js +1 -1
  137. package/src/Strategy/ShortcutModule.d.ts +1 -1
  138. package/src/Strategy/ShortcutModule.js +1 -1
  139. package/src/Strategy/StyledColumnModule.d.ts +0 -1
  140. package/src/Strategy/StyledColumnModule.js +0 -21
  141. package/src/Strategy/TeamSharingModule.d.ts +1 -0
  142. package/src/Strategy/TeamSharingModule.js +5 -5
  143. package/src/Strategy/ToolPanelModule.d.ts +0 -1
  144. package/src/Strategy/ToolPanelModule.js +0 -23
  145. package/src/Utilities/Constants/DocumentationLinkConstants.js +1 -1
  146. package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
  147. package/src/Utilities/Constants/GeneralConstants.js +1 -0
  148. package/src/Utilities/Defaults/DefaultSettingsPanel.js +5 -4
  149. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +2 -1
  150. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +294 -0
  151. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +1 -1
  152. package/src/Utilities/Extensions/ArrayExtensions.d.ts +2 -0
  153. package/src/Utilities/Extensions/ArrayExtensions.js +4 -0
  154. package/src/Utilities/Helpers/AdaptableHelper.d.ts +3 -4
  155. package/src/Utilities/Helpers/AdaptableHelper.js +18 -58
  156. package/src/Utilities/Helpers/Helper.d.ts +2 -0
  157. package/src/Utilities/Helpers/Helper.js +4 -0
  158. package/src/Utilities/ObjectFactory.js +6 -6
  159. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +3 -2
  160. package/src/Utilities/Services/AggregatedScalarLiveValue.js +14 -9
  161. package/src/Utilities/Services/CellPopupService.js +0 -1
  162. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +1 -1
  163. package/src/Utilities/Services/LicenseService/index.d.ts +3 -0
  164. package/src/Utilities/Services/LicenseService/index.js +1 -181
  165. package/src/Utilities/Services/MetamodelService.d.ts +1 -1
  166. package/src/Utilities/Services/MetamodelService.js +6 -3
  167. package/src/Utilities/Services/QueryLanguageService.d.ts +1 -1
  168. package/src/Utilities/Services/QueryLanguageService.js +2 -1
  169. package/src/Utilities/Services/RowEditService.d.ts +3 -2
  170. package/src/Utilities/Services/RowEditService.js +3 -1
  171. package/src/Utilities/Services/SummaryService.d.ts +19 -0
  172. package/src/Utilities/Services/SummaryService.js +29 -0
  173. package/src/Utilities/license/decode.js +1 -65
  174. package/src/Utilities/license/hashing.js +1 -43
  175. package/src/View/AdaptableView.js +1 -3
  176. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.js +2 -2
  177. package/src/View/BulkUpdate/BulkUpdatePopup.js +1 -1
  178. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.d.ts +1 -1
  179. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +2 -2
  180. package/src/View/CalculatedColumn/utils.d.ts +1 -1
  181. package/src/View/CellSummary/CellSummaryPopup.js +1 -1
  182. package/src/View/Comments/CommentsPopup.js +12 -8
  183. package/src/View/Components/AdaptableDateInput/index.d.ts +1 -1
  184. package/src/View/Components/NewScopeComponent.js +34 -1
  185. package/src/View/Components/Popups/AdaptableLoadingScreen.d.ts +6 -5
  186. package/src/View/Components/Popups/AdaptableLoadingScreen.js +19 -9
  187. package/src/View/Components/Popups/AdaptableToaster.js +1 -1
  188. package/src/View/Components/Popups/GridCellPopup/GridCellPopup.js +1 -1
  189. package/src/View/Components/Popups/WindowPopups/windowFactory.d.ts +1 -0
  190. package/src/View/Components/Popups/WindowPopups/windowFactory.js +3 -0
  191. package/src/View/Components/Selectors/PermittedValuesSelector.js +1 -1
  192. package/src/View/CustomSort/CustomSortSummary.js +1 -1
  193. package/src/View/DataChangeHistory/DataChangeHistoryGrid.js +8 -8
  194. package/src/View/GridFilter/GridFilterViewPanel.js +7 -3
  195. package/src/View/GridInfo/GridInfoPopup/GridInfoPopup.js +2 -3
  196. package/src/View/Layout/TransposedPopup.d.ts +3 -0
  197. package/src/View/Layout/TransposedPopup.js +194 -0
  198. package/src/View/Layout/Wizard/LayoutWizard.js +1 -1
  199. package/src/View/License/LicenseWatermark.js +1 -61
  200. package/src/View/Notes/NotesPopup.js +9 -11
  201. package/src/View/SpecialColumnSettingsWizardStep.js +4 -4
  202. package/src/View/Theme/ThemeSelector.js +3 -3
  203. package/src/agGrid/ActionColumnRenderer.js +7 -6
  204. package/src/agGrid/Adaptable.d.ts +3 -455
  205. package/src/agGrid/Adaptable.js +8 -5292
  206. package/src/agGrid/AdaptableAgGrid.d.ts +351 -0
  207. package/src/agGrid/AdaptableAgGrid.js +3936 -0
  208. package/src/agGrid/AdaptableLogger.js +77 -11
  209. package/src/agGrid/AgGridAdapter.d.ts +62 -0
  210. package/src/agGrid/AgGridAdapter.js +577 -0
  211. package/src/agGrid/AgGridColumnAdapter.d.ts +56 -0
  212. package/src/agGrid/AgGridColumnAdapter.js +824 -0
  213. package/src/agGrid/AgGridMenuAdapter.d.ts +28 -0
  214. package/src/agGrid/AgGridMenuAdapter.js +271 -0
  215. package/src/agGrid/AgGridOptionsService.d.ts +12 -0
  216. package/src/agGrid/AgGridOptionsService.js +54 -0
  217. package/src/agGrid/BadgeRenderer.js +1 -1
  218. package/src/agGrid/CheckboxRenderer.js +1 -1
  219. package/src/agGrid/FilterWrapper.d.ts +2 -2
  220. package/src/agGrid/FilterWrapper.js +1 -1
  221. package/src/agGrid/attachAddaptableColumnTypes.d.ts +12 -12
  222. package/src/agGrid/defaultAdaptableOptions.d.ts +3 -0
  223. package/src/{Utilities/Defaults/DefaultAdaptableOptions.js → agGrid/defaultAdaptableOptions.js} +70 -9
  224. package/src/agGrid/editors/AdaptableDateEditor/index.js +2 -2
  225. package/src/agGrid/editors/AdaptableNumberEditor/index.js +2 -2
  226. package/src/components/ColorPicker/ColorPicker.d.ts +1 -1
  227. package/src/components/Datepicker/index.d.ts +1 -1
  228. package/src/components/InfiniteTable/index.js +2 -2
  229. package/src/components/Input/index.d.ts +1 -1
  230. package/src/components/List/ListGroupItem/index.d.ts +1 -1
  231. package/src/components/Modal/index.d.ts +1 -0
  232. package/src/components/Modal/index.js +4 -3
  233. package/src/components/Select/Select.d.ts +2 -0
  234. package/src/components/Select/Select.js +2 -2
  235. package/src/components/icons/index.js +2 -0
  236. package/src/components/icons/rows.d.ts +3 -0
  237. package/src/components/icons/rows.js +4 -0
  238. package/src/env.js +2 -2
  239. package/src/metamodel/adaptable.metamodel.d.ts +74 -11
  240. package/src/metamodel/adaptable.metamodel.js +1 -9313
  241. package/src/migration/AdaptableUpgradeHelper.d.ts +38 -0
  242. package/src/migration/AdaptableUpgradeHelper.js +48 -0
  243. package/src/migration/VersionUpgrade.d.ts +8 -0
  244. package/src/migration/VersionUpgrade.js +11 -0
  245. package/src/migration/VersionUpgrade17.d.ts +18 -0
  246. package/src/migration/VersionUpgrade17.js +342 -0
  247. package/src/migration/VersionUpgrade18.d.ts +5 -0
  248. package/src/migration/VersionUpgrade18.js +6 -0
  249. package/src/parser/src/types.d.ts +5 -0
  250. package/src/types.d.ts +7 -3
  251. package/tsconfig.esm.tsbuildinfo +1 -1
  252. package/src/Utilities/Defaults/DefaultAdaptableOptions.d.ts +0 -2
  253. package/src/Utilities/Services/Interface/IRowEditService.d.ts +0 -3
  254. package/src/Utilities/Services/Interface/IRowEditService.js +0 -1
  255. package/src/View/Components/ScopeComponent.d.ts +0 -24
  256. package/src/View/Components/ScopeComponent.js +0 -133
  257. package/src/View/Export/Wizard/ReportScopeWizard.d.ts +0 -17
  258. package/src/View/Export/Wizard/ReportScopeWizard.js +0 -47
  259. package/src/agGrid/agGridHelper.d.ts +0 -57
  260. package/src/agGrid/agGridHelper.js +0 -686
  261. package/src/agGrid/agGridMenuHelper.d.ts +0 -46
  262. package/src/agGrid/agGridMenuHelper.js +0 -668
  263. /package/src/AdaptableOptions/{CommentsOptions.js → CommentOptions.js} +0 -0
  264. /package/src/AdaptableOptions/{NotesOptions.js → NoteOptions.js} +0 -0
@@ -0,0 +1,824 @@
1
+ import { ModuleNames, } from '@ag-grid-community/core';
2
+ import merge from 'lodash/merge';
3
+ import { FilterWrapperFactory } from './FilterWrapper';
4
+ import { FloatingFilterWrapperFactory } from './FloatingFilterWrapper';
5
+ import { convertAdaptableStyleToCSS, getVariableColor, normalizeStyleForAgGrid, } from '../Utilities/Helpers/StyleHelper';
6
+ import StringExtensions from '../Utilities/Extensions/StringExtensions';
7
+ import { createBaseContext } from '../Utilities/ObjectFactory';
8
+ import clamp from 'lodash/clamp';
9
+ import tinycolor from 'tinycolor2';
10
+ import UIHelper from '../View/UIHelper';
11
+ import { getPercentBarRendererForColumn } from './PercentBarRenderer';
12
+ import { getBadgeRendererForColumn } from './BadgeRenderer';
13
+ import Helper from '../Utilities/Helpers/Helper';
14
+ import { ROW_SUMMARY_ROW_ID } from '../PredefinedConfig/Common/RowSummary';
15
+ export class AgGridColumnAdapter {
16
+ constructor(adaptableInstance) {
17
+ this.adaptableInstance = adaptableInstance;
18
+ this.colDefPropertyCache = new Map();
19
+ }
20
+ destroy() {
21
+ this.adaptableInstance = null;
22
+ this.colDefPropertyCache.clear();
23
+ this.colDefPropertyCache = null;
24
+ }
25
+ get adaptableApi() {
26
+ return this.adaptableInstance.api;
27
+ }
28
+ get adaptableOptions() {
29
+ return this.adaptableInstance.adaptableOptions;
30
+ }
31
+ get agGridApi() {
32
+ return this.adaptableInstance.agGridAdapter.getAgGridApi();
33
+ }
34
+ setColDefProperty(col, propertyName, propertyGetter) {
35
+ var _a;
36
+ const colId = col.getColId();
37
+ const colDef = col.getColDef();
38
+ const colSetupInfo = {
39
+ col,
40
+ colDef,
41
+ colId,
42
+ };
43
+ const userKey = `user.${colId}.${propertyName}`;
44
+ const adaptableKey = `adaptable.${colId}.${propertyName}`;
45
+ const value = colDef[propertyName];
46
+ const isUserDefined = value !== this.colDefPropertyCache.get(adaptableKey);
47
+ if (isUserDefined) {
48
+ this.colDefPropertyCache.set(userKey, value);
49
+ }
50
+ const userValue = this.colDefPropertyCache.get(userKey);
51
+ const adaptableValue = propertyGetter(userValue);
52
+ if (adaptableValue != null) {
53
+ this.colDefPropertyCache.set(adaptableKey, adaptableValue);
54
+ }
55
+ let theValue = adaptableValue !== null && adaptableValue !== void 0 ? adaptableValue : userValue;
56
+ this.adaptableInstance.forPlugins((plugin) => {
57
+ if (plugin.interceptSetupColumnProperty) {
58
+ theValue = plugin.interceptSetupColumnProperty(colSetupInfo, propertyName, theValue, this.adaptableApi);
59
+ }
60
+ });
61
+ if (propertyName === 'aggFunc') {
62
+ if (colDef[propertyName] !== (theValue !== null && theValue !== void 0 ? theValue : null)) {
63
+ (_a = this.agGridApi) === null || _a === void 0 ? void 0 : _a.setColumnAggFunc(colId, theValue !== null && theValue !== void 0 ? theValue : null);
64
+ }
65
+ }
66
+ if (theValue === undefined && colDef[propertyName] === undefined) {
67
+ // already undefined, so don't set an own property to the same undefined value
68
+ return;
69
+ }
70
+ colDef[propertyName] = theValue;
71
+ }
72
+ getUserColDefProperty(columnId, propertyName) {
73
+ const userKey = `user.${columnId}.${propertyName}`;
74
+ return this.colDefPropertyCache.get(userKey);
75
+ }
76
+ setupColumns() {
77
+ const cols = this.agGridApi.getColumns();
78
+ // this needs to be here, before the other setup below
79
+ // so the setup methods below reference the correct columns in adaptable store
80
+ cols.forEach((col) => {
81
+ const colDef = col.getColDef();
82
+ const colId = col.getColId();
83
+ const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
84
+ const colSetupInfo = {
85
+ col,
86
+ colDef,
87
+ colId,
88
+ abColumn,
89
+ };
90
+ this.setupColumnCellRenderer(colSetupInfo);
91
+ this.setupColumnCellStyle(colSetupInfo);
92
+ this.setupColumnCellClass(colSetupInfo);
93
+ this.setupColumnTooltipValueGetter(colSetupInfo);
94
+ this.setupColumnValueGetter(colSetupInfo);
95
+ this.setupColumnFilter(colSetupInfo);
96
+ this.setupColumnFloatingFilter(colSetupInfo);
97
+ this.setupColumnValueFormatter(colSetupInfo);
98
+ this.setupColumnEditable(colSetupInfo);
99
+ this.setupColumnValueSetter(colSetupInfo);
100
+ this.setupColumnComparator(colSetupInfo);
101
+ this.setupColumnCellEditor(colSetupInfo);
102
+ this.setupColumnHeader(colSetupInfo);
103
+ this.setupColumnQuickFilerText(colSetupInfo);
104
+ this.setupColumnAllowedAggFuncs(colSetupInfo);
105
+ this.setupColumnKeyCreator(colSetupInfo);
106
+ // this is just to make sure that AG Grid does NOT infer the cellDataType
107
+ // https://github.com/AdaptableTools/adaptable/issues/2230 should render it obsolete
108
+ this.setupColumnCellDataType(colSetupInfo);
109
+ });
110
+ }
111
+ triggerSetupColumnKeyCreator(colId) {
112
+ const col = this.agGridApi.getColumn(colId);
113
+ const colDef = col.getColDef();
114
+ const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
115
+ const colSetupInfo = {
116
+ col,
117
+ colDef,
118
+ colId,
119
+ abColumn,
120
+ };
121
+ this.setupColumnKeyCreator(colSetupInfo);
122
+ }
123
+ setupColumnValueGetter({ col }) {
124
+ // need this here if we want plugins to intercept
125
+ this.setColDefProperty(col, 'valueGetter', (userValue) => {
126
+ return userValue;
127
+ });
128
+ }
129
+ setupColumnCellClass({ col, colId, abColumn }) {
130
+ this.setColDefProperty(col, 'cellClass', (userCellClass) => {
131
+ const formatColumns = this.adaptableApi.formatColumnApi.internalApi.getFormatColumnWithStyleClassNameForColumn(abColumn);
132
+ const quickSearchStyleClassName = this.adaptableApi.quickSearchApi.getQuickSearchStyle().ClassName;
133
+ const hasQuickSearchStyleClassName = StringExtensions.IsNotNullOrEmpty(quickSearchStyleClassName);
134
+ const cellClass = (params) => {
135
+ const gridCell = this.adaptableInstance.getGridCellFromRowNode(params.node, abColumn.columnId);
136
+ // if a Visual Data export is in progress, we are interested only in the Excel Style Class
137
+ if (this.adaptableApi.exportApi.internalApi.isVisualDataExportInProgress()) {
138
+ const userDefinedCellClass = typeof userCellClass === 'function' ? userCellClass(params) : userCellClass;
139
+ const cellClassKey = this.getExcelClassNameForCell(colId, gridCell.primaryKeyValue, userDefinedCellClass);
140
+ return this.adaptableApi.internalApi
141
+ .getReportService()
142
+ .getExcelStyleIdForCellClassKey(cellClassKey);
143
+ }
144
+ const isQuickSearchActive = hasQuickSearchStyleClassName && this.isQuickSearchActive(gridCell, params);
145
+ const editableClassName = this.getEditableCellClass(gridCell, params);
146
+ const readonlyClassName = this.getReadonlyCellClass(gridCell, params);
147
+ const highlightAlertClassName = this.getAlertCellClass(gridCell, params);
148
+ const flashingClassName = this.getFlashingCellClass(gridCell, params);
149
+ const styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(colId);
150
+ const hasStyledColumn = !!styledColumn && !styledColumn.IsSuspended;
151
+ const noteClassName = this.getNoteCellClassName(gridCell, params);
152
+ const commentsClassName = this.getCommentCellClassName(gridCell, params);
153
+ const returnValue = [
154
+ typeof userCellClass === 'function' ? userCellClass(params) : userCellClass,
155
+ !hasStyledColumn && formatColumns.length
156
+ ? this.getFormatColumnCellClass(formatColumns, abColumn, params)
157
+ : null,
158
+ isQuickSearchActive ? quickSearchStyleClassName : null,
159
+ editableClassName,
160
+ readonlyClassName,
161
+ highlightAlertClassName,
162
+ flashingClassName,
163
+ noteClassName,
164
+ commentsClassName,
165
+ ]
166
+ // we flatten the array because some rules ('userCellClass' etc) might return a string[]
167
+ .flat()
168
+ .filter((x) => !!x);
169
+ const result = returnValue.length ? returnValue : undefined;
170
+ return result;
171
+ };
172
+ return cellClass;
173
+ });
174
+ }
175
+ setupColumnCellStyle({ col, colId, abColumn }) {
176
+ this.setColDefProperty(col, 'cellStyle', (userCellStyle) => {
177
+ const quickSearchStyle = this.getQuickSearchCellStyle();
178
+ const hasQuickSearchStyle = quickSearchStyle != undefined;
179
+ const cellStyle = (params) => {
180
+ const gridCell = this.adaptableInstance.getGridCellFromRowNode(params.node, abColumn.columnId);
181
+ const isQuickSearchActive = hasQuickSearchStyle && this.isQuickSearchActive(gridCell, params);
182
+ const userDefined = typeof userCellStyle === 'function' ? userCellStyle(params) : userCellStyle;
183
+ const result = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, userDefined), this.getReadOnlyCellStyle(gridCell, params)), this.getEditableCellStyle(gridCell, params)), this.getFormatColumnAndStyledColumnCellStyle(gridCell, params)), (isQuickSearchActive ? quickSearchStyle : {})), this.getAlertCellStyle(gridCell, params)), this.getFlashingCellStyle(gridCell, params)), this.getCellHighlightStyle(gridCell, params));
184
+ return normalizeStyleForAgGrid(result);
185
+ };
186
+ return cellStyle;
187
+ });
188
+ }
189
+ setupColumnCellEditor({ colId, col }) {
190
+ const adaptableColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
191
+ const editLookUpItem = this.adaptableApi.userInterfaceApi.getEditLookUpItemForColumn(adaptableColumn);
192
+ const hasRichSelectCellEditor = this.adaptableInstance.agGridAdapter.isModulePresent(ModuleNames.RichSelectModule);
193
+ this.setColDefProperty(col, 'cellEditor', () => {
194
+ if (editLookUpItem) {
195
+ return hasRichSelectCellEditor ? 'agRichSelectCellEditor' : 'agSelectCellEditor';
196
+ }
197
+ });
198
+ this.setColDefProperty(col, 'cellEditorPopup', () => {
199
+ // as specified in https://www.ag-grid.com/react-data-grid/provided-cell-editors/#rich-select-cell-editor
200
+ // agRichSelectCellEditor should always set cellEditorPopup=true. Otherwise the editor will be clipped to the cell contents
201
+ if (editLookUpItem && hasRichSelectCellEditor) {
202
+ return true;
203
+ }
204
+ });
205
+ this.setColDefProperty(col, 'cellEditorParams', (params) => {
206
+ if (editLookUpItem) {
207
+ return (params) => {
208
+ const gridCell = this.adaptableInstance.getGridCellFromRowNode(params === null || params === void 0 ? void 0 : params.node, colId);
209
+ return {
210
+ values: this.adaptableApi.userInterfaceApi.getEditLookUpValuesForEditLookUpItem(editLookUpItem, gridCell),
211
+ };
212
+ };
213
+ }
214
+ });
215
+ }
216
+ setupColumnCellRenderer({ col, colId, abColumn }) {
217
+ this.setColDefProperty(col, 'cellRenderer', () => {
218
+ const styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(abColumn.columnId);
219
+ if (styledColumn && !styledColumn.IsSuspended) {
220
+ if (styledColumn.PercentBarStyle) {
221
+ return getPercentBarRendererForColumn(styledColumn, abColumn, this.adaptableApi);
222
+ }
223
+ if (styledColumn.BadgeStyle) {
224
+ return getBadgeRendererForColumn(styledColumn, abColumn, this.adaptableApi);
225
+ }
226
+ if (styledColumn.SparkLineStyle) {
227
+ return 'agSparklineCellRenderer';
228
+ }
229
+ }
230
+ });
231
+ this.setColDefProperty(col, 'cellRendererParams', (userDefined) => {
232
+ const styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(abColumn.columnId);
233
+ if (styledColumn && !styledColumn.IsSuspended) {
234
+ if (styledColumn.SparkLineStyle) {
235
+ const sparklineOptions = merge({}, userDefined === null || userDefined === void 0 ? void 0 : userDefined.sparklineOptions, styledColumn.SparkLineStyle.options);
236
+ return Object.assign(Object.assign({}, userDefined), { sparklineOptions });
237
+ }
238
+ }
239
+ });
240
+ }
241
+ setupColumnTooltipValueGetter({ col, colId, abColumn }) {
242
+ let hasTooptip = false;
243
+ this.setColDefProperty(col, 'tooltipValueGetter', () => {
244
+ const styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(colId);
245
+ if (styledColumn &&
246
+ !styledColumn.IsSuspended &&
247
+ styledColumn.PercentBarStyle &&
248
+ styledColumn.PercentBarStyle.ToolTipText) {
249
+ hasTooptip = true;
250
+ if (styledColumn === null || styledColumn === void 0 ? void 0 : styledColumn.PercentBarStyle) {
251
+ return (params) => {
252
+ const min = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMinValue(styledColumn, abColumn, params.node, params.value);
253
+ const max = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMaxValue(styledColumn, abColumn, params.node, params.value);
254
+ const textOptions = styledColumn.PercentBarStyle.ToolTipText;
255
+ let returnValue = '';
256
+ if (textOptions.includes('CellValue')) {
257
+ returnValue = params.value;
258
+ }
259
+ if (textOptions.includes('PercentageValue')) {
260
+ const clampedValue = Helper.clamp(params.value, min, max);
261
+ const percentageValue = ((clampedValue - min) / (max - min)) * 100;
262
+ returnValue += ' ' + `(${percentageValue.toFixed(0)}%)`;
263
+ }
264
+ return returnValue ? returnValue : params.value;
265
+ };
266
+ }
267
+ }
268
+ });
269
+ }
270
+ setupColumnQuickFilerText({ col, abColumn }) {
271
+ this.setColDefProperty(col, 'getQuickFilterText', (userGetQuickFilterText) => {
272
+ if (userGetQuickFilterText) {
273
+ return userGetQuickFilterText;
274
+ }
275
+ return (params) => {
276
+ const visibleCoulmnsMap = this.adaptableApi.layoutApi.getCurrentVisibleColumnIdsMap();
277
+ const isVisible = visibleCoulmnsMap[abColumn.columnId];
278
+ if (!isVisible) {
279
+ return '';
280
+ }
281
+ return this.adaptableInstance.getDisplayValueFromRowNode(params.node, abColumn.columnId);
282
+ };
283
+ });
284
+ }
285
+ setupColumnAllowedAggFuncs({ col, abColumn }) {
286
+ this.setColDefProperty(col, 'allowedAggFuncs', () => {
287
+ return abColumn.availableAggregationFunctions;
288
+ });
289
+ }
290
+ setupColumnKeyCreator(columnSetupInfo) {
291
+ const { col, abColumn } = columnSetupInfo;
292
+ const adaptableOptions = this.adaptableOptions;
293
+ this.setColDefProperty(col, 'keyCreator', (userPropertyValue) => {
294
+ return (params) => {
295
+ var _a;
296
+ if (typeof userPropertyValue === 'function') {
297
+ return userPropertyValue(params);
298
+ }
299
+ const value = params.value;
300
+ if (this.adaptableInstance.agGridAdapter.getLiveGridOptions().groupAllowUnbalanced) {
301
+ return value;
302
+ }
303
+ const balancedGroupsKey = (_a = adaptableOptions.groupingOptions) === null || _a === void 0 ? void 0 : _a.balancedGroupsKey;
304
+ if (!balancedGroupsKey) {
305
+ return value;
306
+ }
307
+ let groupBalancedGroupsUnderKeyValue = typeof balancedGroupsKey === 'function'
308
+ ? balancedGroupsKey({
309
+ adaptableApi: this.adaptableApi,
310
+ userName: this.adaptableOptions.userName,
311
+ adaptableId: this.adaptableOptions.adaptableId,
312
+ adaptableColumn: abColumn,
313
+ params,
314
+ })
315
+ : balancedGroupsKey;
316
+ return value === null || value === undefined ? groupBalancedGroupsUnderKeyValue : value;
317
+ };
318
+ });
319
+ }
320
+ setupColumnCellDataType(columnSetupInfo) {
321
+ const { col } = columnSetupInfo;
322
+ // AG Grid introduced since v30.x an inferred cellDataType
323
+ // the problem is that it breaks the default value formatter and/or editor (especially for Date columns)
324
+ this.setColDefProperty(col, 'cellDataType', () => {
325
+ return false;
326
+ });
327
+ }
328
+ setupColumnHeader({ col, abColumn }) {
329
+ var _a, _b;
330
+ const previousColumnHeader = (_a = col === null || col === void 0 ? void 0 : col.getColDef()) === null || _a === void 0 ? void 0 : _a.headerName;
331
+ this.setColDefProperty(col, 'headerName', (userHeaderName) => {
332
+ var _a;
333
+ // set the default to the AG Grid provided values
334
+ // from https://github.com/ag-grid/ag-grid/blob/v26.1.0/community-modules/core/src/ts/columns/columnModel.ts#L2515
335
+ let resultHeaderName = userHeaderName !== null && userHeaderName !== void 0 ? userHeaderName : StringExtensions.CamelCaseToHumanText(col.getColDef().field);
336
+ const layoutCustomHeader = (_a = this.adaptableApi.layoutApi.getCurrentLayout().ColumnHeadersMap) === null || _a === void 0 ? void 0 : _a[col.getColId()];
337
+ if (layoutCustomHeader) {
338
+ resultHeaderName = layoutCustomHeader;
339
+ }
340
+ // required here for the initial layout rendering
341
+ // Removed by JW, 3 october 2023; i don't think we need it and it overrides stuff unnecessarily
342
+ // abColumn.friendlyName = resultHeaderName;
343
+ return resultHeaderName;
344
+ });
345
+ const newColumnHeader = (_b = col === null || col === void 0 ? void 0 : col.getColDef()) === null || _b === void 0 ? void 0 : _b.headerName;
346
+ return previousColumnHeader !== newColumnHeader;
347
+ }
348
+ setupColumnFilter({ col, colDef }) {
349
+ this.setColDefProperty(col, 'filter', () => {
350
+ if (!colDef.filter) {
351
+ return;
352
+ }
353
+ if (!this.adaptableOptions.columnFilterOptions.useAdaptableColumnFiltering) {
354
+ return;
355
+ }
356
+ this.agGridApi.destroyFilter(col);
357
+ return FilterWrapperFactory(this.adaptableInstance);
358
+ });
359
+ }
360
+ setupColumnFloatingFilter({ col, colDef }) {
361
+ const isFloatingFilterDisabled = !colDef.floatingFilter ||
362
+ !this.adaptableOptions.columnFilterOptions.useAdaptableColumnFiltering;
363
+ this.setColDefProperty(col, 'floatingFilterComponent', () => {
364
+ if (isFloatingFilterDisabled) {
365
+ return;
366
+ }
367
+ return FloatingFilterWrapperFactory(this.adaptableInstance);
368
+ });
369
+ this.setColDefProperty(col, 'suppressFloatingFilterButton', () => {
370
+ return !isFloatingFilterDisabled;
371
+ });
372
+ }
373
+ setupColumnValueFormatter({ col, abColumn }) {
374
+ this.setColDefProperty(col, 'valueFormatter', (userPropertyValue) => {
375
+ const activeFormatColumnsWithDisplayFormat = this.adaptableApi.formatColumnApi.internalApi.getFormatColumnsWithDisplayFormatForColumn(abColumn);
376
+ if (!activeFormatColumnsWithDisplayFormat.length) {
377
+ return;
378
+ }
379
+ return (params) => {
380
+ const { node, value } = params;
381
+ const mostRelevantFormatColumn = this.adaptableApi.formatColumnApi.internalApi.getMostRelevantFormatColumnForColumn(activeFormatColumnsWithDisplayFormat, abColumn, { node, value });
382
+ if (!mostRelevantFormatColumn) {
383
+ // ALL FormatColumns are conditional and NONE of them are relevant for this row
384
+ return value;
385
+ }
386
+ const options = mostRelevantFormatColumn.DisplayFormat.Options;
387
+ if (mostRelevantFormatColumn.DisplayFormat.Formatter === 'NumberFormatter') {
388
+ // change the Number format - if the scope allows it
389
+ if (this.adaptableApi.scopeApi.isColumnInNumericScope(abColumn, mostRelevantFormatColumn.Scope)) {
390
+ return this.adaptableApi.formatColumnApi.internalApi.getNumberFormattedValue(params.value, params.node, abColumn, options);
391
+ }
392
+ }
393
+ if (mostRelevantFormatColumn.DisplayFormat.Formatter === 'DateFormatter') {
394
+ // change the Date format - if the scope allows it
395
+ if (this.adaptableApi.scopeApi.isColumnInDateScope(abColumn, mostRelevantFormatColumn.Scope)) {
396
+ return this.adaptableApi.formatColumnApi.internalApi.getDateFormattedValue(params.value, params.node, abColumn, options);
397
+ }
398
+ }
399
+ if (mostRelevantFormatColumn.DisplayFormat.Formatter === 'StringFormatter') {
400
+ // change the String format - if the scope allows it
401
+ if (this.adaptableApi.scopeApi.isColumnInStringsScope(abColumn, mostRelevantFormatColumn.Scope)) {
402
+ return this.adaptableApi.formatColumnApi.internalApi.getStringFormattedValue(params.value, params.node, abColumn, options);
403
+ }
404
+ }
405
+ // should NEVER arrive at this line, but just to be sure
406
+ return value;
407
+ };
408
+ });
409
+ }
410
+ setupColumnEditable({ col }) {
411
+ this.setColDefProperty(col, 'editable', (userValue) => {
412
+ // if AG Grid defines the column as NOT editable, we don't mess with it
413
+ if (typeof userValue === 'boolean' && userValue === false) {
414
+ return userValue;
415
+ }
416
+ const cellEditableFn = this.adaptableOptions.editOptions.isCellEditable;
417
+ const editableCallback = (params) => {
418
+ // Adaptable Row Summarie rows are not editable
419
+ if (params.node.data[ROW_SUMMARY_ROW_ID]) {
420
+ return false;
421
+ }
422
+ if (!cellEditableFn) {
423
+ return typeof userValue === 'function' ? userValue(params) : userValue;
424
+ }
425
+ const gridCell = this.adaptableInstance.getGridCellFromRowNode(params.node, params.column.getColId());
426
+ const cellEditableContext = {
427
+ gridCell,
428
+ adaptableApi: this.adaptableApi,
429
+ userName: this.adaptableOptions.userName,
430
+ adaptableId: this.adaptableOptions.adaptableId,
431
+ };
432
+ return cellEditableFn(cellEditableContext);
433
+ };
434
+ return editableCallback;
435
+ });
436
+ }
437
+ setupColumnValueSetter({ col, colId, abColumn }) {
438
+ this.setColDefProperty(col, 'valueSetter', (userValueSetter) => {
439
+ var _a;
440
+ const preventEditAlertsForColumn = this.adaptableApi.alertApi.internalApi
441
+ .getAlertDefinitionsWithPreventEdit()
442
+ .filter((alertDefinition) => {
443
+ return this.adaptableApi.scopeApi.isColumnInScope(abColumn, alertDefinition.Scope);
444
+ });
445
+ const noValidations = !preventEditAlertsForColumn.length && !((_a = this.adaptableOptions.editOptions) === null || _a === void 0 ? void 0 : _a.validateOnServer);
446
+ if (noValidations) {
447
+ return;
448
+ }
449
+ const valueSetter = (params) => {
450
+ var _a;
451
+ const field = params.column.getColDef().field;
452
+ if (noValidations) {
453
+ //TODO also consider the case when userValueSetter is a string
454
+ if (typeof userValueSetter === 'function') {
455
+ return userValueSetter(params);
456
+ }
457
+ // we allowed it go reach this point
458
+ // just to run isCellEditable
459
+ // and since this has already run and we have no other validations
460
+ // just assign the new value and exit
461
+ if (field) {
462
+ params.data[field] = params.newValue;
463
+ }
464
+ return true;
465
+ }
466
+ const cellDataChangedInfo = this.adaptableApi.internalApi.buildDataChangedInfo({
467
+ oldValue: params.oldValue,
468
+ newValue: params.newValue,
469
+ column: this.adaptableApi.columnApi.getColumnWithColumnId(params.column.getColId()),
470
+ primaryKeyValue: this.adaptableInstance.getPrimaryKeyValueFromRowNode(params.node, params.api),
471
+ rowNode: params.node,
472
+ trigger: 'edit',
473
+ });
474
+ if (cellDataChangedInfo.oldValue === cellDataChangedInfo.newValue) {
475
+ return true;
476
+ }
477
+ /**
478
+ * Validate on the future row, with the new value.
479
+ * structuredClone fails, it contains functions.
480
+ */
481
+ const newRow = Object.assign(Object.assign({}, params.node), { data: Object.assign({}, params.node.data) });
482
+ newRow.data[field] = params.newValue;
483
+ const cellDataChangeInfoForSyncValidation = Object.assign(Object.assign({}, cellDataChangedInfo), { rowNode: newRow });
484
+ if (!this.adaptableInstance.ValidationService.performValidation(cellDataChangeInfoForSyncValidation)) {
485
+ return false;
486
+ }
487
+ const onServerValidationCompleted = () => { };
488
+ if ((_a = this.adaptableOptions.editOptions) === null || _a === void 0 ? void 0 : _a.validateOnServer) {
489
+ this.adaptableInstance.ValidationService.performServerValidation(cellDataChangedInfo, {
490
+ onServerValidationCompleted,
491
+ })();
492
+ }
493
+ //TODO also consider the case when userValueSetter is a string
494
+ if (typeof userValueSetter === 'function') {
495
+ return userValueSetter(params);
496
+ }
497
+ if (field) {
498
+ params.data[field] = params.newValue;
499
+ }
500
+ else {
501
+ throw `Cannot edit a column without a field - column id was ${colId}`;
502
+ }
503
+ return true;
504
+ };
505
+ return valueSetter;
506
+ });
507
+ }
508
+ setupColumnComparator({ col, colId, abColumn }) {
509
+ const customSort = this.adaptableApi.customSortApi.getCustomSortForColumn(colId);
510
+ const columnSortComparer = this.adaptableApi.customSortApi.internalApi.getCustomSortComparer(abColumn.columnId);
511
+ const comparatorGetter = (propName) => {
512
+ return () => {
513
+ return this.adaptableApi.columnApi.internalApi.getActiveColumnComparator(colId, customSort, columnSortComparer);
514
+ };
515
+ };
516
+ this.setColDefProperty(col, 'comparator', comparatorGetter('comparator'));
517
+ this.setColDefProperty(col, 'pivotComparator', comparatorGetter('pivotComparator'));
518
+ }
519
+ getExcelClassNameForCell(colId, primaryKeyValue, userDefinedCellClass) {
520
+ let excelClassName = `--excel-cell-${colId}-${primaryKeyValue}`;
521
+ if (excelClassName.indexOf(' ') > 0) {
522
+ excelClassName = excelClassName.replace(/\s/g, '_');
523
+ }
524
+ return userDefinedCellClass != null
525
+ ? `${excelClassName}-${Array.isArray(userDefinedCellClass)
526
+ ? userDefinedCellClass.join('-')
527
+ : userDefinedCellClass}`
528
+ : excelClassName;
529
+ }
530
+ isQuickSearchActive(gridCell, params) {
531
+ let quickSearchValue = this.adaptableApi.quickSearchApi.getQuickSearchValue();
532
+ if (StringExtensions.IsNullOrEmpty(quickSearchValue)) {
533
+ return false;
534
+ }
535
+ if (gridCell.column.isExcludedFromQuickSearch) {
536
+ return false;
537
+ }
538
+ if (!params.node) {
539
+ return false;
540
+ }
541
+ if (!gridCell.isPivotCell &&
542
+ !this.adaptableApi.optionsApi.getQuickSearchOptions().runQuickSearchOnRowGroups &&
543
+ params.node.group) {
544
+ return false;
545
+ }
546
+ if (!this.adaptableApi.optionsApi.getQuickSearchOptions().runQuickSearchOnPivotColumns &&
547
+ gridCell.isPivotCell) {
548
+ return false;
549
+ }
550
+ if (this.adaptableApi.optionsApi.getQuickSearchOptions().runQuickSearchOnPivotColumns &&
551
+ gridCell.isPivotCell) {
552
+ gridCell.displayValue = params.value;
553
+ }
554
+ const ignoreCase = !this.adaptableOptions.quickSearchOptions.runQuickSearchWithCaseSensitivity;
555
+ const displayValue = ignoreCase
556
+ ? String(gridCell.displayValue).toLocaleLowerCase()
557
+ : String(gridCell.displayValue);
558
+ const i = ignoreCase ? String(quickSearchValue).toLocaleLowerCase() : String(quickSearchValue);
559
+ const applyQuickSearchFunction = this.adaptableOptions.quickSearchOptions.runBespokeQuickSearch;
560
+ if (applyQuickSearchFunction) {
561
+ const quickSearchContext = Object.assign(Object.assign({}, createBaseContext(this.adaptableApi)), { gridCell, quickSearchValue: quickSearchValue });
562
+ return applyQuickSearchFunction(quickSearchContext);
563
+ }
564
+ return displayValue.indexOf(i) !== -1;
565
+ }
566
+ getEditableCellClass(gridCell, params) {
567
+ const editableCellStyle = this.adaptableApi.userInterfaceApi.getEditableCellStyle();
568
+ if (!(editableCellStyle === null || editableCellStyle === void 0 ? void 0 : editableCellStyle.ClassName)) {
569
+ return null;
570
+ }
571
+ const isCellEditable = this.adaptableApi.gridApi.isCellEditable(gridCell);
572
+ return isCellEditable ? editableCellStyle.ClassName : null;
573
+ }
574
+ getReadonlyCellClass(gridCell, params) {
575
+ const readonlyCellStyle = this.adaptableApi.userInterfaceApi.getReadOnlyCellStyle();
576
+ if (!(readonlyCellStyle === null || readonlyCellStyle === void 0 ? void 0 : readonlyCellStyle.ClassName)) {
577
+ return null;
578
+ }
579
+ const isCellReadonly = !this.adaptableApi.gridApi.isCellEditable(gridCell);
580
+ return isCellReadonly ? readonlyCellStyle.ClassName : null;
581
+ }
582
+ getAlertCellClass(gridCell, params) {
583
+ var _a, _b;
584
+ const alert = this.adaptableApi.alertApi.internalApi.getAdaptableAlertWithHighlightCell(gridCell.column.columnId, params.node);
585
+ const highlightCell = (_b = (_a = alert === null || alert === void 0 ? void 0 : alert.alertDefinition) === null || _a === void 0 ? void 0 : _a.AlertProperties) === null || _b === void 0 ? void 0 : _b.HighlightCell;
586
+ return typeof highlightCell === 'object' && (highlightCell === null || highlightCell === void 0 ? void 0 : highlightCell.ClassName)
587
+ ? highlightCell === null || highlightCell === void 0 ? void 0 : highlightCell.ClassName
588
+ : null;
589
+ }
590
+ getFlashingCellClass(gridcell, params) {
591
+ var _a, _b, _c;
592
+ const primaryKey = params.node.aggData ? params.node.id : gridcell.primaryKeyValue;
593
+ const flashingCell = this.adaptableApi.flashingCellApi.internalApi.getAdaptableFlashingCellFor(primaryKey, gridcell.column.columnId);
594
+ if (!flashingCell) {
595
+ return;
596
+ }
597
+ return flashingCell.direction === 'up'
598
+ ? (_a = flashingCell.flashingCellDefinition.UpChangeStyle) === null || _a === void 0 ? void 0 : _a.ClassName
599
+ : flashingCell.direction === 'down'
600
+ ? (_b = flashingCell.flashingCellDefinition.DownChangeStyle) === null || _b === void 0 ? void 0 : _b.ClassName
601
+ : flashingCell.direction === 'neutral'
602
+ ? (_c = flashingCell.flashingCellDefinition.NeutralChangeStyle) === null || _c === void 0 ? void 0 : _c.ClassName
603
+ : undefined;
604
+ }
605
+ getNoteCellClassName(gridCell, params) {
606
+ if (!this.adaptableApi.internalApi.getModuleService().isModuleAvailable('Notes')) {
607
+ return;
608
+ }
609
+ if (!this.adaptableApi.notesApi.internalApi.areNotesAvailable()) {
610
+ return;
611
+ }
612
+ const cellPosition = {
613
+ PrimaryKeyValue: gridCell.primaryKeyValue,
614
+ ColumnId: gridCell.column.columnId,
615
+ };
616
+ const cellNotes = this.adaptableApi.notesApi.getCellNotes(cellPosition);
617
+ if (!(cellNotes === null || cellNotes === void 0 ? void 0 : cellNotes.length)) {
618
+ return undefined;
619
+ }
620
+ return 'ab-Cell-Note';
621
+ }
622
+ getCommentCellClassName(gridCell, params) {
623
+ if (!this.adaptableApi.internalApi.getModuleService().isModuleAvailable('Comments')) {
624
+ return;
625
+ }
626
+ if (!this.adaptableApi.commentApi.internalApi.areCommentsAvailable()) {
627
+ return;
628
+ }
629
+ const position = {
630
+ PrimaryKeyValue: gridCell.primaryKeyValue,
631
+ ColumnId: gridCell.column.columnId,
632
+ };
633
+ const cellComments = this.adaptableApi.commentApi.getCommentThread(position);
634
+ if (!cellComments) {
635
+ return undefined;
636
+ }
637
+ return 'ab-Cell-Comment';
638
+ }
639
+ getFormatColumnCellClass(formatColumns, abColumn, params) {
640
+ const classNames = formatColumns
641
+ .map((formatColumn) => {
642
+ var _a, _b;
643
+ if (((_a = formatColumn.Style) === null || _a === void 0 ? void 0 : _a.ClassName) &&
644
+ this.adaptableApi.formatColumnApi.internalApi.isFormatColumnRelevantForColumn(formatColumn, abColumn, params)) {
645
+ return (_b = formatColumn.Style) === null || _b === void 0 ? void 0 : _b.ClassName;
646
+ }
647
+ })
648
+ .filter((x) => !!x);
649
+ return classNames;
650
+ }
651
+ getQuickSearchCellStyle() {
652
+ const quickSearchStyle = this.adaptableApi.quickSearchApi.getQuickSearchStyle();
653
+ if (!quickSearchStyle || StringExtensions.IsNotNullOrEmpty(quickSearchStyle.ClassName)) {
654
+ return undefined;
655
+ }
656
+ return convertAdaptableStyleToCSS(quickSearchStyle);
657
+ }
658
+ getReadOnlyCellStyle(gridCell, params) {
659
+ const editableCellStyle = this.adaptableApi.userInterfaceApi.getReadOnlyCellStyle();
660
+ if (!editableCellStyle) {
661
+ return undefined;
662
+ }
663
+ if (gridCell) {
664
+ if (!this.adaptableApi.gridApi.isCellEditable(gridCell)) {
665
+ return convertAdaptableStyleToCSS(editableCellStyle);
666
+ }
667
+ }
668
+ return undefined;
669
+ }
670
+ getEditableCellStyle(gridCell, params) {
671
+ const editableCellStyle = this.adaptableApi.userInterfaceApi.getEditableCellStyle();
672
+ if (!editableCellStyle) {
673
+ return undefined;
674
+ }
675
+ if (gridCell) {
676
+ if (this.adaptableApi.gridApi.isCellEditable(gridCell)) {
677
+ return convertAdaptableStyleToCSS(editableCellStyle);
678
+ }
679
+ }
680
+ return undefined;
681
+ }
682
+ /**
683
+ * The combination of styled column and format cells
684
+ * This functiond decides when the two can be merged.
685
+ */
686
+ getFormatColumnAndStyledColumnCellStyle(gridCell, params) {
687
+ let styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(gridCell.column.columnId);
688
+ let styledColumnStyle = {};
689
+ if (styledColumn && !(styledColumn === null || styledColumn === void 0 ? void 0 : styledColumn.IsSuspended)) {
690
+ const styledCellStyle = this.getStyledColumnStyle(styledColumn, gridCell.column, params);
691
+ // for percentbar we want to merge
692
+ if (styledColumn.PercentBarStyle || styledColumn.BadgeStyle) {
693
+ styledColumnStyle = styledCellStyle;
694
+ }
695
+ else {
696
+ // For other ones wo do not want to merge
697
+ return styledCellStyle;
698
+ }
699
+ }
700
+ const activeFormatColumnsWithStyle = this.adaptableApi.formatColumnApi.internalApi.getFormatColumnsWithStyleForColumn(gridCell.column);
701
+ return Object.assign(Object.assign({}, this.getFormatColumnCellStyle(gridCell.column, activeFormatColumnsWithStyle, params)), styledColumnStyle);
702
+ }
703
+ getStyledColumnStyle(styledColumn, abColumn, params) {
704
+ let style = {};
705
+ const gradientStyle = styledColumn === null || styledColumn === void 0 ? void 0 : styledColumn.GradientStyle;
706
+ if (params.value === undefined) {
707
+ return;
708
+ }
709
+ let colValue = params.value;
710
+ if (this.adaptableApi.gridApi.isGroupRowNode(params.node)) {
711
+ if (styledColumn.IncludeGroupedRows) {
712
+ const minColumnValue = this.adaptableApi.styledColumnApi.internalApi.getMinValueForNumericColumn(abColumn);
713
+ const maxColumnValue = this.adaptableApi.styledColumnApi.internalApi.getMaxValueForNumericColumn(abColumn);
714
+ /**
715
+ * Color should always be in bounds, it should not overflow.
716
+ * If the value is out of range, it shoul set the maximum/minimum color.
717
+ */
718
+ colValue = clamp(params.value, minColumnValue, maxColumnValue);
719
+ }
720
+ else {
721
+ return style;
722
+ }
723
+ }
724
+ if (gradientStyle) {
725
+ const min = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMinValue(styledColumn, abColumn, params.node, colValue);
726
+ const max = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMaxValue(styledColumn, abColumn, params.node, colValue);
727
+ let cellBackColor;
728
+ let reverseGradient = false;
729
+ if (gradientStyle.ColumnComparison) {
730
+ cellBackColor = gradientStyle.ColumnComparison.Color;
731
+ }
732
+ else {
733
+ const matchingRange = this.adaptableApi.styledColumnApi.internalApi.findRangeForColumn(gradientStyle.CellRanges, abColumn, gradientStyle.RangeValueType, colValue);
734
+ if (matchingRange) {
735
+ cellBackColor = matchingRange.Color;
736
+ reverseGradient = matchingRange.ReverseGradient;
737
+ }
738
+ }
739
+ const increase = Math.abs(max - min);
740
+ const percentage = ((colValue - min) / increase) * 100;
741
+ let alpha = Number((percentage / 100).toPrecision(2));
742
+ if (reverseGradient) {
743
+ alpha = 1 - alpha;
744
+ }
745
+ const preparedColor = getVariableColor(cellBackColor);
746
+ // if no range match, do not apply color (black in this case)
747
+ if (cellBackColor) {
748
+ style.backgroundColor = tinycolor(preparedColor).setAlpha(alpha).toRgbString();
749
+ }
750
+ }
751
+ if (styledColumn.PercentBarStyle && styledColumn.PercentBarStyle.CellText) {
752
+ style.paddingTop = 0;
753
+ style.paddingBottom = 0;
754
+ }
755
+ return style;
756
+ }
757
+ getFormatColumnCellStyle(abColumn, activeFormatColumnsWithStyle, params) {
758
+ if (!activeFormatColumnsWithStyle.length) {
759
+ return {};
760
+ }
761
+ const relevantFormatColumnsWithStyle = activeFormatColumnsWithStyle.filter((formatColumn) => {
762
+ return this.adaptableApi.formatColumnApi.internalApi.isFormatColumnRelevantForColumn(formatColumn, abColumn, params);
763
+ });
764
+ return this.getFormatColumnAdaptableStyle(relevantFormatColumnsWithStyle);
765
+ }
766
+ getFormatColumnAdaptableStyle(formatColumns) {
767
+ // first has more precedence, then they need to be applied in reverse order
768
+ return formatColumns.reduceRight((style, formatColumn) => {
769
+ const formatColumnStyle = formatColumn.Style
770
+ ? convertAdaptableStyleToCSS(formatColumn.Style)
771
+ : {};
772
+ if (formatColumn.CellAlignment) {
773
+ switch (formatColumn.CellAlignment) {
774
+ case 'Left':
775
+ style.textAlign = 'left';
776
+ break;
777
+ case 'Right':
778
+ style.textAlign = 'right';
779
+ break;
780
+ case 'Center':
781
+ style.textAlign = 'center';
782
+ break;
783
+ }
784
+ }
785
+ return Object.assign(Object.assign({}, style), formatColumnStyle);
786
+ }, {});
787
+ }
788
+ getAlertCellStyle(gridCell, params) {
789
+ const alert = this.adaptableApi.alertApi.internalApi.getAdaptableAlertWithHighlightCell(gridCell.column.columnId, params.node);
790
+ if (alert) {
791
+ const highlightCell = alert.alertDefinition.AlertProperties.HighlightCell;
792
+ if (typeof highlightCell === 'object') {
793
+ return convertAdaptableStyleToCSS(highlightCell);
794
+ }
795
+ return {
796
+ backgroundColor: UIHelper.getColorByMessageType(alert.alertDefinition.MessageType),
797
+ };
798
+ }
799
+ }
800
+ getFlashingCellStyle(gridCell, params) {
801
+ var _a;
802
+ const primaryKey = params.node.aggData ? params.node.id : gridCell.primaryKeyValue;
803
+ const flashingCell = this.adaptableApi.flashingCellApi.internalApi.getAdaptableFlashingCellFor(primaryKey, gridCell.column.columnId);
804
+ if (!flashingCell) {
805
+ return {};
806
+ }
807
+ return convertAdaptableStyleToCSS((_a = (flashingCell.direction === 'up'
808
+ ? flashingCell.flashingCellDefinition.UpChangeStyle
809
+ : flashingCell.direction === 'down'
810
+ ? flashingCell.flashingCellDefinition.DownChangeStyle
811
+ : flashingCell.flashingCellDefinition.NeutralChangeStyle)) !== null && _a !== void 0 ? _a : {});
812
+ }
813
+ getCellHighlightStyle(gridCell, params) {
814
+ const cellHightlight = this.adaptableApi.internalApi
815
+ .getSystemState()
816
+ .HighlightedCells.find((cellHighlightInfo) => {
817
+ return (gridCell.column.columnId === cellHighlightInfo.columnId &&
818
+ cellHighlightInfo.primaryKeyValue === gridCell.primaryKeyValue);
819
+ });
820
+ if (cellHightlight) {
821
+ return convertAdaptableStyleToCSS(cellHightlight.highlightStyle);
822
+ }
823
+ }
824
+ }