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