@adaptabletools/adaptable 18.0.0-canary.4 → 18.0.0-canary.5

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