@adaptabletools/adaptable 24.0.2 → 24.0.4

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 (117) hide show
  1. package/devtools.d.ts +506 -5
  2. package/devtools.js +11 -1
  3. package/index.css +15 -5
  4. package/package.json +1 -1
  5. package/src/AdaptableInterfaces/IAdaptable.d.ts +13 -1
  6. package/src/AdaptableOptions/DataImportOptions.d.ts +1 -1
  7. package/src/AdaptableOptions/ExportOptions.d.ts +2 -2
  8. package/src/AdaptableState/Common/AdaptableFormat.d.ts +2 -10
  9. package/src/AdaptableState/Common/RowSummary.d.ts +2 -0
  10. package/src/AdaptableState/LayoutState.d.ts +1 -1
  11. package/src/Api/AdaptableApi.d.ts +12 -0
  12. package/src/Api/GridApi.d.ts +13 -3
  13. package/src/Api/Implementation/AdaptableApiImpl.d.ts +1 -0
  14. package/src/Api/Implementation/AdaptableApiImpl.js +3 -0
  15. package/src/Api/Implementation/AlertApiImpl.js +2 -0
  16. package/src/Api/Implementation/FlashingCellApiImpl.js +3 -8
  17. package/src/Api/Implementation/GridApiImpl.js +1 -1
  18. package/src/Api/Internal/AlertInternalApi.d.ts +7 -0
  19. package/src/Api/Internal/AlertInternalApi.js +42 -9
  20. package/src/Api/Internal/CalculatedColumnInternalApi.js +25 -3
  21. package/src/Api/Internal/ExportInternalApi.d.ts +2 -0
  22. package/src/Api/Internal/ExportInternalApi.js +39 -3
  23. package/src/Api/Internal/LayoutInternalApi.d.ts +11 -1
  24. package/src/Api/Internal/LayoutInternalApi.js +34 -3
  25. package/src/Api/Internal/NoteInternalApi.d.ts +12 -0
  26. package/src/Api/Internal/NoteInternalApi.js +11 -0
  27. package/src/EnvVars.d.ts +1 -0
  28. package/src/EnvVars.js +1 -0
  29. package/src/Redux/Store/AdaptableStore.js +4 -7
  30. package/src/Strategy/FlashingCellModule.js +4 -1
  31. package/src/Utilities/Helpers/CellValueHelper.d.ts +20 -0
  32. package/src/Utilities/Helpers/CellValueHelper.js +35 -0
  33. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +26 -1
  34. package/src/Utilities/Services/CalculatedColumnExpressionService.js +175 -42
  35. package/src/Utilities/Services/DataService.js +10 -6
  36. package/src/Utilities/Services/FlashingCellService.d.ts +12 -0
  37. package/src/Utilities/Services/FlashingCellService.js +40 -3
  38. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +12 -0
  39. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +22 -1
  40. package/src/Utilities/Services/QueryLanguageService.d.ts +17 -1
  41. package/src/Utilities/Services/QueryLanguageService.js +75 -2
  42. package/src/Utilities/Services/RowSummaryService.d.ts +2 -0
  43. package/src/Utilities/Services/RowSummaryService.js +6 -1
  44. package/src/Utilities/license/instanceLicense.d.ts +12 -0
  45. package/src/Utilities/license/instanceLicense.js +10 -0
  46. package/src/Utilities/license/licenseStatus.d.ts +26 -0
  47. package/src/Utilities/license/licenseStatus.js +72 -0
  48. package/src/View/Components/CellPopup/index.js +15 -10
  49. package/src/View/GridInfo/GridInfoPopup.js +6 -1
  50. package/src/View/Layout/TransposedPopup.js +1 -0
  51. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +3 -5
  52. package/src/View/Layout/Wizard/sections/AggregationsSection.js +10 -24
  53. package/src/View/Layout/Wizard/sections/RowSummarySection.js +5 -1
  54. package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.d.ts +5 -1
  55. package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.js +6 -3
  56. package/src/agGrid/AdaptableAgGrid.d.ts +87 -17
  57. package/src/agGrid/AdaptableAgGrid.js +586 -168
  58. package/src/agGrid/AdaptableFilterHandler.d.ts +2 -0
  59. package/src/agGrid/AdaptableFilterHandler.js +34 -0
  60. package/src/agGrid/AgGridAdapter.d.ts +19 -1
  61. package/src/agGrid/AgGridAdapter.js +39 -12
  62. package/src/agGrid/AgGridColumnAdapter.d.ts +2 -0
  63. package/src/agGrid/AgGridColumnAdapter.js +124 -78
  64. package/src/agGrid/AgGridExportAdapter.d.ts +5 -0
  65. package/src/agGrid/AgGridExportAdapter.js +31 -0
  66. package/src/agGrid/AgGridMenuAdapter.js +1 -1
  67. package/src/agGrid/applyGlobalGridOptions.d.ts +9 -0
  68. package/src/agGrid/applyGlobalGridOptions.js +36 -0
  69. package/src/agGrid/cellRenderers/BadgeRenderer.js +22 -0
  70. package/src/agGrid/columnMinMaxCache.d.ts +33 -0
  71. package/src/agGrid/columnMinMaxCache.js +50 -0
  72. package/src/devTools/PerfStore.d.ts +218 -0
  73. package/src/devTools/PerfStore.js +717 -0
  74. package/src/devTools/index.d.ts +33 -0
  75. package/src/devTools/index.js +132 -56
  76. package/src/devTools/logBuffer.d.ts +17 -0
  77. package/src/devTools/logBuffer.js +33 -0
  78. package/src/devTools/memoryInfo.d.ts +15 -0
  79. package/src/devTools/memoryInfo.js +229 -0
  80. package/src/devTools/memoryRoots.d.ts +41 -0
  81. package/src/devTools/memoryRoots.js +136 -0
  82. package/src/devTools/perfContext.d.ts +5 -0
  83. package/src/devTools/perfContext.js +155 -0
  84. package/src/devTools/perfInstrumentation.d.ts +13 -0
  85. package/src/devTools/perfInstrumentation.js +78 -0
  86. package/src/env.js +2 -2
  87. package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -1
  88. package/src/layout-manager/src/expandAllRowGroups.d.ts +6 -0
  89. package/src/layout-manager/src/expandAllRowGroups.js +13 -0
  90. package/src/layout-manager/src/index.js +18 -10
  91. package/src/setupDevTools.js +560 -106
  92. package/tsconfig.esm.tsbuildinfo +1 -1
  93. package/vendor/components/Combobox/index.js +1 -1
  94. package/vendor/components/Combobox/index.js.map +1 -1
  95. package/vendor/components/Radio/index.d.ts.map +1 -1
  96. package/vendor/components/Radio/index.js +1 -1
  97. package/vendor/components/Radio/index.js.map +1 -1
  98. package/vendor/components/Resizable/index.d.ts +14 -9
  99. package/vendor/components/Resizable/index.d.ts.map +1 -1
  100. package/vendor/components/Resizable/index.js +23 -0
  101. package/vendor/components/Resizable/index.js.map +1 -1
  102. package/vendor/components/Resizable/resizableUtils.d.ts +24 -13
  103. package/vendor/components/Resizable/resizableUtils.d.ts.map +1 -1
  104. package/vendor/components/Resizable/resizableUtils.js +13 -3
  105. package/vendor/components/Resizable/resizableUtils.js.map +1 -1
  106. package/vendor/components/index.css +12 -5
  107. package/vendor/components/ui/combobox.js +1 -1
  108. package/vendor/components/ui/combobox.js.map +1 -1
  109. package/vendor/components/ui/input.js +1 -1
  110. package/vendor/components/ui/input.js.map +1 -1
  111. package/vendor/components/ui/select.js +1 -1
  112. package/vendor/components/ui/select.js.map +1 -1
  113. package/vendor/components/ui/textarea.js +1 -1
  114. package/vendor/components/ui/textarea.js.map +1 -1
  115. package/vendor/components/ui/tooltip.d.ts.map +1 -1
  116. package/vendor/components/ui/tooltip.js +3 -1
  117. package/vendor/components/ui/tooltip.js.map +1 -1
@@ -1,3 +1,4 @@
1
+ import { getPerfRecorder } from '../devTools/PerfStore';
1
2
  import * as FlashingCellRedux from '../Redux/ActionsReducers/FlashingCellRedux';
2
3
  import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
3
4
  import { ArrayExtensions } from '../Utilities/Extensions/ArrayExtensions';
@@ -61,6 +62,7 @@ export class FlashingCellModule extends AdaptableModuleBase {
61
62
  }
62
63
  const relevantFlashingCellDefinitions = this.getFlashingCellDefinitionsForDataChange(activeFlashingCellDefinitions, cellDataChangedInfo);
63
64
  if (ArrayExtensions.IsNotNullOrEmpty(relevantFlashingCellDefinitions)) {
65
+ getPerfRecorder(this.api.optionsApi.getAdaptableId())?.count('flashes');
64
66
  this.showFlashingCellsForDefinitions(cellDataChangedInfo, relevantFlashingCellDefinitions);
65
67
  }
66
68
  }
@@ -106,7 +108,7 @@ export class FlashingCellModule extends AdaptableModuleBase {
106
108
  return triggeredFlashingCells;
107
109
  }
108
110
  showFlashingCellsForDefinitions(cellDataChangedInfo, flashingCellDefinitions = []) {
109
- const allColumnIds = this.api.columnApi.getUIAvailableColumns().map((c) => c.columnId);
111
+ let allColumnIds;
110
112
  const columnDataType = cellDataChangedInfo.column.dataType;
111
113
  const numeric = columnDataType === 'number';
112
114
  const isComparableType = numeric || columnDataType === 'date';
@@ -128,6 +130,7 @@ export class FlashingCellModule extends AdaptableModuleBase {
128
130
  let flashTarget = this.api.flashingCellApi.getFlashingCellFlashTarget(flashingCellDefinition);
129
131
  const flashColumnIds = { [cellDataChangedInfo.column.columnId]: true };
130
132
  if (flashTarget === 'row' || flashTarget?.includes?.('row')) {
133
+ allColumnIds ??= this.api.columnApi.getUIAvailableColumns().map((c) => c.columnId);
131
134
  allColumnIds.forEach((colId) => {
132
135
  flashColumnIds[colId] = true;
133
136
  });
@@ -0,0 +1,20 @@
1
+ import { AdaptableColumn } from '../../AdaptableState/Common/AdaptableColumn';
2
+ /**
3
+ * Whether a cell value is unchanged: loose equality (`==`), with `NaN` equal to `NaN` and two
4
+ * `Date` values equal when they hold the same time.
5
+ */
6
+ export declare function areCellValuesEqual(oldValue: any, newValue: any): boolean;
7
+ /** A column that reads row data, with the field it reads */
8
+ export interface DataBackedColumn {
9
+ column: AdaptableColumn;
10
+ /** the column's `field`, or its column id when it has none */
11
+ field: string;
12
+ /** the field is a dotted path (`quote.spread`) */
13
+ isNested: boolean;
14
+ }
15
+ /**
16
+ * The columns whose values come from the row data. Calculated, Free Text, Action, FDC3 and the
17
+ * columns AG Grid generates (row group, selection, pivot result, pivot total) are left out.
18
+ * With `suppressFieldDotNotation` (the AG Grid option) a dotted field is a plain property name.
19
+ */
20
+ export declare function getDataBackedColumns(columns: AdaptableColumn[], suppressFieldDotNotation?: boolean): DataBackedColumn[];
@@ -0,0 +1,35 @@
1
+ import { FDC3_COLUMN_TYPE } from '../../AdaptableState/Common/AdaptableColumn';
2
+ export function areCellValuesEqual(oldValue, newValue) {
3
+ if (oldValue == newValue) {
4
+ return true;
5
+ }
6
+ if (typeof oldValue === 'number' && typeof newValue === 'number') {
7
+ return Number.isNaN(oldValue) && Number.isNaN(newValue);
8
+ }
9
+ if (oldValue instanceof Date && newValue instanceof Date) {
10
+ return Object.is(oldValue.getTime(), newValue.getTime());
11
+ }
12
+ return false;
13
+ }
14
+ export function getDataBackedColumns(columns, suppressFieldDotNotation = false) {
15
+ const dataBackedColumns = [];
16
+ for (const column of columns) {
17
+ if (column.isCalculatedColumn ||
18
+ column.isFreeTextColumn ||
19
+ column.isActionColumn ||
20
+ column.isGeneratedRowGroupColumn ||
21
+ column.isGeneratedSelectionColumn ||
22
+ column.isGeneratedPivotResultColumn ||
23
+ column.isPivotTotalColumn ||
24
+ column.columnTypes?.includes(FDC3_COLUMN_TYPE)) {
25
+ continue;
26
+ }
27
+ const field = column.field ?? column.columnId;
28
+ dataBackedColumns.push({
29
+ column,
30
+ field,
31
+ isNested: !suppressFieldDotNotation && field.includes('.'),
32
+ });
33
+ }
34
+ return dataBackedColumns;
35
+ }
@@ -14,7 +14,14 @@ export declare class CalculatedColumnExpressionService implements ICalculatedCol
14
14
  * ties a column Uuid to its node handle + grid-refresh subscription.
15
15
  */
16
16
  private aggregatedColumnBindings;
17
+ private dependencyCache;
17
18
  constructor(adaptableApi: AdaptableApi);
19
+ private getDependencyCache;
20
+ /**
21
+ * The scalar Calculated Columns whose value depends on the column, directly or through other
22
+ * Calculated Columns. Callers must not change the array.
23
+ */
24
+ getDependentScalarCalculatedColumns(columnId: string): CalculatedColumn[];
18
25
  private getComputedValueStore;
19
26
  buildSyntheticCellDataChangedInfosForCalcColumns(cellDataChangedInfo: CellDataChangedInfo): CellDataChangedInfo[];
20
27
  destroy(): void;
@@ -24,10 +31,28 @@ export declare class CalculatedColumnExpressionService implements ICalculatedCol
24
31
  inferCalculatedColumnTypes(calculatedColumn: Pick<CalculatedColumn, 'Type' | 'Expression'>): InferredCalculatedColumnTypes;
25
32
  getLiveRefreshTarget(calculatedColumn: CalculatedColumn): LiveRefreshTarget | undefined;
26
33
  getObservableCalculatedColumnsAffectedByColumn(columnId: string): ObservableCalculatedColumnRefresh[];
34
+ private findObservableCalculatedColumnsAffectedByColumn;
35
+ getAggregatedCalculatedColumnsAffectedByColumn(columnId: string): string[];
36
+ private findAggregatedCalculatedColumnsAffectedByColumn;
27
37
  isCalculatedColumnQueryValid(calculatedColumn: Pick<CalculatedColumn, 'Type' | 'Expression'>, calculatedColumnId?: string): boolean;
28
38
  evaluateCalculatedColumnQuery(calculatedColumn: CalculatedColumn, rowNode: IRowNode): any;
29
39
  bindAggregatedCalculatedColumn(calculatedColumn: CalculatedColumn): void;
30
40
  unbindAggregatedCalculatedColumn(calculatedColumn: CalculatedColumn): void;
31
41
  }
42
+ /**
43
+ * The row as it was before the changes: a shallow copy of `currentData` with each changed field
44
+ * put back to its old value. For a dotted field only the objects along its path are copied, so
45
+ * `currentData` is never written to. With `suppressFieldDotNotation` (the AG Grid option) a dotted
46
+ * field is a plain property name.
47
+ */
48
+ export declare function buildPreviousRowData(currentData: Record<string, any>, changes: {
49
+ field: string;
50
+ oldValue: any;
51
+ }[], suppressFieldDotNotation?: boolean): Record<string, any>;
32
52
  export declare function buildSyntheticCellDataChangedInfosForCalcColumns(adaptableApi: AdaptableApi, info: CellDataChangedInfo): CellDataChangedInfo[];
33
- export declare function expandCellDataChangedInfosWithCalculatedColumns(adaptableApi: AdaptableApi, cellDataChangedInfos: CellDataChangedInfo[]): CellDataChangedInfo[];
53
+ /**
54
+ * Adds a `calculatedColumnChange` for every scalar Calculated Column the changes alter, one per
55
+ * row and column. `oldData` is the row object before the changes, when they all belong to one
56
+ * replaced row.
57
+ */
58
+ export declare function expandCellDataChangedInfosWithCalculatedColumns(adaptableApi: AdaptableApi, cellDataChangedInfos: CellDataChangedInfo[], oldData?: Record<string, any>): CellDataChangedInfo[];
@@ -3,15 +3,48 @@ import { CalculatedColumnModuleId } from '../Constants/ModuleConstants';
3
3
  import { expressionKindForCalculatedColumnType, getCalculatedColumnType, } from '../../AdaptableState/CalculatedColumnState';
4
4
  import { createHostExpressionContext, evaluate } from "../../../vendor/aql/index.js";
5
5
  import { createAdaptableAqlHost } from '../../aql/createAdaptableAqlHost';
6
- import Helper from '../Helpers/Helper';
6
+ import { areCellValuesEqual } from '../Helpers/CellValueHelper';
7
7
  import { CALCULATED_COLUMN_INVALID_CELL_VALUE } from '../Constants/GeneralConstants';
8
8
  export class CalculatedColumnExpressionService {
9
9
  adaptableApi;
10
10
  aggregatedColumnBindings = new Map();
11
+ dependencyCache;
11
12
  constructor(adaptableApi) {
12
13
  this.adaptableApi = adaptableApi;
13
14
  this.adaptableApi = adaptableApi;
14
15
  }
16
+ getDependencyCache() {
17
+ const calculatedColumns = this.adaptableApi.calculatedColumnApi.getCalculatedColumnState().CalculatedColumns;
18
+ const columns = this.adaptableApi.columnApi.getColumns();
19
+ const functionsGeneration = this.adaptableApi.internalApi
20
+ .getQueryLanguageService()
21
+ .getFunctionsGeneration();
22
+ const cache = this.dependencyCache;
23
+ if (cache &&
24
+ cache.calculatedColumns === calculatedColumns &&
25
+ cache.columns === columns &&
26
+ cache.functionsGeneration === functionsGeneration) {
27
+ return cache;
28
+ }
29
+ this.dependencyCache = {
30
+ calculatedColumns,
31
+ columns,
32
+ functionsGeneration,
33
+ observable: new Map(),
34
+ aggregated: new Map(),
35
+ dependentScalar: new Map(),
36
+ };
37
+ return this.dependencyCache;
38
+ }
39
+ getDependentScalarCalculatedColumns(columnId) {
40
+ const { dependentScalar } = this.getDependencyCache();
41
+ let calculatedColumns = dependentScalar.get(columnId);
42
+ if (!calculatedColumns) {
43
+ calculatedColumns = collectDependentScalarCalculatedColumns(this.adaptableApi, columnId);
44
+ dependentScalar.set(columnId, calculatedColumns);
45
+ }
46
+ return calculatedColumns;
47
+ }
15
48
  getComputedValueStore() {
16
49
  return this.adaptableApi.internalApi.getQueryLanguageService().getComputedValueStore();
17
50
  }
@@ -25,6 +58,7 @@ export class CalculatedColumnExpressionService {
25
58
  });
26
59
  this.aggregatedColumnBindings.clear();
27
60
  this.aggregatedColumnBindings = null;
61
+ this.dependencyCache = undefined;
28
62
  }
29
63
  resolveCalculatedColumnQuery(calculatedColumn) {
30
64
  return this.adaptableApi.internalApi
@@ -98,6 +132,15 @@ export class CalculatedColumnExpressionService {
98
132
  return { kind: 'columns', columnIds: [calculatedColumn.ColumnId] };
99
133
  }
100
134
  getObservableCalculatedColumnsAffectedByColumn(columnId) {
135
+ const { observable } = this.getDependencyCache();
136
+ let affected = observable.get(columnId);
137
+ if (!affected) {
138
+ affected = this.findObservableCalculatedColumnsAffectedByColumn(columnId);
139
+ observable.set(columnId, affected);
140
+ }
141
+ return affected;
142
+ }
143
+ findObservableCalculatedColumnsAffectedByColumn(columnId) {
101
144
  const queryLanguageService = this.adaptableApi.internalApi.getQueryLanguageService();
102
145
  const affected = [];
103
146
  for (const calculatedColumn of this.adaptableApi.calculatedColumnApi.getCalculatedColumns()) {
@@ -120,6 +163,30 @@ export class CalculatedColumnExpressionService {
120
163
  }
121
164
  return affected;
122
165
  }
166
+ getAggregatedCalculatedColumnsAffectedByColumn(columnId) {
167
+ const { aggregated } = this.getDependencyCache();
168
+ let affected = aggregated.get(columnId);
169
+ if (!affected) {
170
+ affected = this.findAggregatedCalculatedColumnsAffectedByColumn(columnId);
171
+ aggregated.set(columnId, affected);
172
+ }
173
+ return affected;
174
+ }
175
+ findAggregatedCalculatedColumnsAffectedByColumn(columnId) {
176
+ const queryLanguageService = this.adaptableApi.internalApi.getQueryLanguageService();
177
+ const affected = [];
178
+ for (const calculatedColumn of this.adaptableApi.calculatedColumnApi.getCalculatedColumns()) {
179
+ const query = this.resolveCalculatedColumnQuery(calculatedColumn);
180
+ if (!query.text || query.kind !== 'aggregated') {
181
+ continue;
182
+ }
183
+ const dependencies = queryLanguageService.getExpressionDependencies(query.text, CalculatedColumnModuleId);
184
+ if (dependencies?.anyColumn || dependencies?.columns.includes(columnId)) {
185
+ affected.push(calculatedColumn.ColumnId);
186
+ }
187
+ }
188
+ return affected;
189
+ }
123
190
  isCalculatedColumnQueryValid(calculatedColumn, calculatedColumnId) {
124
191
  const query = this.resolveCalculatedColumnQuery(calculatedColumn);
125
192
  if (!query.text) {
@@ -253,25 +320,53 @@ function collectDependentScalarCalculatedColumns(adaptableApi, rootColumnId) {
253
320
  }
254
321
  return collected;
255
322
  }
256
- function buildShadowRowData(adaptableApi, info) {
257
- const shadowData = Helper.cloneObject(info.rowNode?.data ?? info.rowData ?? {});
258
- const fieldName = info.column.field ?? info.column.columnId;
259
- adaptableApi.internalApi.setValueUsingField(shadowData, fieldName, info.oldValue);
260
- return shadowData;
323
+ export function buildPreviousRowData(currentData, changes, suppressFieldDotNotation = false) {
324
+ const previousData = { ...currentData };
325
+ for (const { field, oldValue } of changes) {
326
+ if (suppressFieldDotNotation || !field.includes('.')) {
327
+ previousData[field] = oldValue;
328
+ continue;
329
+ }
330
+ const path = field.split('.');
331
+ let target = previousData;
332
+ for (let index = 0; index < path.length - 1 && target; index++) {
333
+ const next = target[path[index]];
334
+ if (next == null || typeof next !== 'object') {
335
+ target = undefined;
336
+ break;
337
+ }
338
+ target[path[index]] = Array.isArray(next) ? [...next] : { ...next };
339
+ target = target[path[index]];
340
+ }
341
+ if (target) {
342
+ target[path[path.length - 1]] = oldValue;
343
+ }
344
+ }
345
+ return previousData;
261
346
  }
262
- function evaluateScalarExpressionWithShadowData(adaptableApi, calculatedColumn, rowNode, shadowData) {
347
+ function createPreviousValuesEvaluator(adaptableApi, rowNode, previousData, suppressFieldDotNotation) {
263
348
  const internalApi = adaptableApi.internalApi;
264
- const moduleFns = internalApi
349
+ const baseFunctions = internalApi
265
350
  .getQueryLanguageService()
266
- .getModuleExpressionFunctionsMap(CalculatedColumnModuleId);
267
- const baseFunctions = { ...moduleFns.scalarFunctions };
351
+ .getModuleExpressionFunctionsMap(CalculatedColumnModuleId).scalarFunctions;
352
+ const previousValues = new Map();
353
+ const evaluateCalculatedColumn = (calculatedColumn) => {
354
+ if (previousValues.has(calculatedColumn.ColumnId)) {
355
+ return previousValues.get(calculatedColumn.ColumnId);
356
+ }
357
+ const value = evaluate(calculatedColumn.Expression, context);
358
+ previousValues.set(calculatedColumn.ColumnId, value);
359
+ return value;
360
+ };
268
361
  const resolveColumnValue = (columnId) => {
269
362
  const childCalculatedColumn = adaptableApi.calculatedColumnApi.getCalculatedColumnForColumnId(columnId);
270
363
  if (childCalculatedColumn && isScalarCalculatedColumn(adaptableApi, childCalculatedColumn)) {
271
- return evaluateScalarExpressionWithShadowData(adaptableApi, childCalculatedColumn, rowNode, shadowData);
364
+ return evaluateCalculatedColumn(childCalculatedColumn);
272
365
  }
273
- const adaptableColumn = adaptableApi.columnApi.getColumnWithColumnId(columnId);
274
- return internalApi.getValueUsingField(shadowData, adaptableColumn?.field ?? columnId);
366
+ const field = adaptableApi.columnApi.getColumnWithColumnId(columnId)?.field ?? columnId;
367
+ return suppressFieldDotNotation
368
+ ? previousData[field]
369
+ : internalApi.getValueUsingField(previousData, field);
275
370
  };
276
371
  const customFunctions = {
277
372
  ...baseFunctions,
@@ -281,65 +376,103 @@ function evaluateScalarExpressionWithShadowData(adaptableApi, calculatedColumn,
281
376
  },
282
377
  FIELD: {
283
378
  ...baseFunctions.FIELD,
284
- handler: (args) => internalApi.getValueUsingField(shadowData, args[0]),
379
+ handler: (args) => internalApi.getValueUsingField(previousData, args[0]),
285
380
  },
286
381
  };
287
- const shadowRowNode = { ...rowNode, data: shadowData };
288
382
  const context = createHostExpressionContext({
289
383
  host: createAdaptableAqlHost(adaptableApi),
290
384
  functions: customFunctions,
291
- rowRef: shadowRowNode,
385
+ rowRef: { ...rowNode, data: previousData },
292
386
  ext: internalApi.buildBaseContext(),
293
387
  });
294
- return evaluate(calculatedColumn.Expression, context);
388
+ return evaluateCalculatedColumn;
295
389
  }
296
- export function buildSyntheticCellDataChangedInfosForCalcColumns(adaptableApi, info) {
297
- if (!info.rowNode ||
298
- info.preventEdit ||
299
- info.trigger === 'undo' ||
300
- info.trigger === 'aggChange' ||
301
- info.trigger === 'calculatedColumnChange') {
302
- return [];
390
+ const isEligibleForCalculatedColumnChanges = (info) => !!info.rowNode &&
391
+ !info.preventEdit &&
392
+ info.trigger !== 'undo' &&
393
+ info.trigger !== 'aggChange' &&
394
+ info.trigger !== 'calculatedColumnChange';
395
+ function buildCalculatedColumnChangesForRow(adaptableApi, rowInfos, oldData) {
396
+ const expressionService = adaptableApi.internalApi.getCalculatedColumnExpressionService();
397
+ const calculatedColumns = [];
398
+ const seenColumnIds = new Set();
399
+ for (const info of rowInfos) {
400
+ for (const calculatedColumn of expressionService.getDependentScalarCalculatedColumns(info.column.columnId)) {
401
+ if (!seenColumnIds.has(calculatedColumn.ColumnId)) {
402
+ seenColumnIds.add(calculatedColumn.ColumnId);
403
+ calculatedColumns.push(calculatedColumn);
404
+ }
405
+ }
303
406
  }
304
- const calculatedColumns = collectDependentScalarCalculatedColumns(adaptableApi, info.column.columnId);
305
407
  if (!calculatedColumns.length) {
306
408
  return [];
307
409
  }
308
- const shadowData = buildShadowRowData(adaptableApi, info);
309
- const expressionService = adaptableApi.internalApi.getCalculatedColumnExpressionService();
310
- const syntheticEvents = [];
311
- calculatedColumns.forEach((calculatedColumn) => {
410
+ const { rowNode, primaryKeyValue } = rowInfos[0];
411
+ const suppressFieldDotNotation = !!adaptableApi.agGridApi.getGridOption('suppressFieldDotNotation');
412
+ const previousData = oldData ??
413
+ buildPreviousRowData(rowNode.data ?? rowInfos[0].rowData ?? {}, rowInfos.map((info) => ({
414
+ field: info.column.field ?? info.column.columnId,
415
+ oldValue: info.oldValue,
416
+ })), suppressFieldDotNotation);
417
+ const evaluatePreviousValue = createPreviousValuesEvaluator(adaptableApi, rowNode, previousData, suppressFieldDotNotation);
418
+ const calculatedColumnChanges = [];
419
+ for (const calculatedColumn of calculatedColumns) {
312
420
  let oldValue;
313
421
  try {
314
- oldValue = evaluateScalarExpressionWithShadowData(adaptableApi, calculatedColumn, info.rowNode, shadowData);
422
+ oldValue = evaluatePreviousValue(calculatedColumn);
315
423
  }
316
424
  catch {
317
- return;
425
+ continue;
318
426
  }
319
- const newValue = expressionService.evaluateCalculatedColumnQuery(calculatedColumn, info.rowNode);
320
- if (oldValue == newValue) {
321
- return;
427
+ const newValue = expressionService.evaluateCalculatedColumnQuery(calculatedColumn, rowNode);
428
+ if (areCellValuesEqual(oldValue, newValue)) {
429
+ continue;
322
430
  }
323
431
  const column = adaptableApi.columnApi.getColumnWithColumnId(calculatedColumn.ColumnId);
324
432
  if (!column) {
325
- return;
433
+ continue;
326
434
  }
327
- syntheticEvents.push(adaptableApi.internalApi.buildCellDataChangedInfo({
435
+ calculatedColumnChanges.push(adaptableApi.internalApi.buildCellDataChangedInfo({
328
436
  oldValue,
329
437
  newValue,
330
438
  column,
331
- primaryKeyValue: info.primaryKeyValue,
332
- rowNode: info.rowNode,
439
+ primaryKeyValue,
440
+ rowNode,
333
441
  trigger: 'calculatedColumnChange',
334
442
  }));
335
- });
336
- return syntheticEvents;
443
+ }
444
+ return calculatedColumnChanges;
337
445
  }
338
- export function expandCellDataChangedInfosWithCalculatedColumns(adaptableApi, cellDataChangedInfos) {
446
+ export function buildSyntheticCellDataChangedInfosForCalcColumns(adaptableApi, info) {
447
+ if (!isEligibleForCalculatedColumnChanges(info)) {
448
+ return [];
449
+ }
450
+ return buildCalculatedColumnChangesForRow(adaptableApi, [info]);
451
+ }
452
+ export function expandCellDataChangedInfosWithCalculatedColumns(adaptableApi, cellDataChangedInfos, oldData) {
339
453
  if (!cellDataChangedInfos.length) {
340
454
  return cellDataChangedInfos;
341
455
  }
342
- const syntheticEvents = cellDataChangedInfos.flatMap((info) => buildSyntheticCellDataChangedInfosForCalcColumns(adaptableApi, info));
456
+ const infosByRow = new Map();
457
+ for (const info of cellDataChangedInfos) {
458
+ if (!isEligibleForCalculatedColumnChanges(info)) {
459
+ continue;
460
+ }
461
+ const rowInfos = infosByRow.get(info.rowNode);
462
+ if (rowInfos) {
463
+ rowInfos.push(info);
464
+ }
465
+ else {
466
+ infosByRow.set(info.rowNode, [info]);
467
+ }
468
+ }
469
+ if (!infosByRow.size) {
470
+ return cellDataChangedInfos;
471
+ }
472
+ const syntheticEvents = [];
473
+ infosByRow.forEach((rowInfos) => {
474
+ syntheticEvents.push(...buildCalculatedColumnChangesForRow(adaptableApi, rowInfos, infosByRow.size === 1 ? oldData : undefined));
475
+ });
343
476
  if (!syntheticEvents.length) {
344
477
  return cellDataChangedInfos;
345
478
  }
@@ -1,4 +1,5 @@
1
1
  import Emitter from '../../Utilities/Emitter';
2
+ import { areCellValuesEqual } from '../Helpers/CellValueHelper';
2
3
  export class DataService {
3
4
  adaptable;
4
5
  emitter;
@@ -38,12 +39,15 @@ export class DataService {
38
39
  }
39
40
  }
40
41
  CreateCellDataChangedEvent(cellDataChangedInfo) {
41
- if (cellDataChangedInfo.newValue != cellDataChangedInfo.oldValue) {
42
- const validationRules = this.adaptable.api.internalApi
43
- .getValidationService()
44
- .getValidationRulesForDataChange(cellDataChangedInfo);
45
- if (validationRules.length) {
46
- cellDataChangedInfo.preventEdit = true;
42
+ if (!areCellValuesEqual(cellDataChangedInfo.oldValue, cellDataChangedInfo.newValue)) {
43
+ const isEdit = cellDataChangedInfo.trigger === 'edit' || cellDataChangedInfo.trigger === 'undo';
44
+ if (isEdit) {
45
+ const validationRules = this.adaptable.api.internalApi
46
+ .getValidationService()
47
+ .getValidationRulesForDataChange(cellDataChangedInfo);
48
+ if (validationRules.length) {
49
+ cellDataChangedInfo.preventEdit = true;
50
+ }
47
51
  }
48
52
  this.emitter.emitSync('BeforeCellDataChanged', cellDataChangedInfo);
49
53
  this.emitter.emitSync('CellDataChanged', cellDataChangedInfo);
@@ -9,11 +9,23 @@ export declare class FlashingCellService implements IAdaptableService {
9
9
  private api;
10
10
  gridCellsCurrentlyFlashing: Record<string, Record<string, TypeUuid>>;
11
11
  flashingCellsMapping: Record<TypeUuid, AdaptableFlashingCell>;
12
+ private flashesToClear;
13
+ private flashClearTimers;
12
14
  constructor(api: AdaptableApi);
13
15
  destroy(): void;
16
+ /**
17
+ * Clears the flash after `duration` ms. The flashes shown in one synchronous turn with the same
18
+ * duration share one timer, started when the turn ends, so none is shorter than its duration.
19
+ */
20
+ scheduleGridCellFlashClear(flashingCell: AdaptableFlashingCell, duration: number): void;
21
+ private startFlashClearTimers;
14
22
  addGridCellFlash(flashingCell: AdaptableFlashingCell): void;
15
23
  clearGridCellFlash(flashingCell: AdaptableFlashingCell): void;
16
24
  clearAllGridCellFlashes(): void;
17
25
  isAnyFlashingCellActive(): boolean;
26
+ /**
27
+ * Refreshes the flashing cells of the row and of its pinned copy, if they are rendered. A row
28
+ * rendered later reads the flash from this service when its cells are first rendered.
29
+ */
18
30
  private refreshGridCells;
19
31
  }
@@ -3,6 +3,8 @@ export class FlashingCellService {
3
3
  api;
4
4
  gridCellsCurrentlyFlashing;
5
5
  flashingCellsMapping;
6
+ flashesToClear;
7
+ flashClearTimers = new Set();
6
8
  constructor(api) {
7
9
  this.api = api;
8
10
  this.gridCellsCurrentlyFlashing = {};
@@ -11,6 +13,34 @@ export class FlashingCellService {
11
13
  destroy() {
12
14
  this.gridCellsCurrentlyFlashing = {};
13
15
  this.flashingCellsMapping = {};
16
+ this.flashesToClear = undefined;
17
+ this.flashClearTimers.forEach((timer) => clearTimeout(timer));
18
+ this.flashClearTimers.clear();
19
+ }
20
+ scheduleGridCellFlashClear(flashingCell, duration) {
21
+ if (!this.flashesToClear) {
22
+ this.flashesToClear = new Map();
23
+ queueMicrotask(() => this.startFlashClearTimers());
24
+ }
25
+ let flashingCells = this.flashesToClear.get(duration);
26
+ if (!flashingCells) {
27
+ flashingCells = [];
28
+ this.flashesToClear.set(duration, flashingCells);
29
+ }
30
+ flashingCells.push(flashingCell);
31
+ }
32
+ startFlashClearTimers() {
33
+ const flashesToClear = this.flashesToClear;
34
+ this.flashesToClear = undefined;
35
+ flashesToClear?.forEach((flashingCells, duration) => {
36
+ const timer = setTimeout(() => {
37
+ this.flashClearTimers.delete(timer);
38
+ this.api.internalApi
39
+ .getAdaptableInstance()
40
+ .runPostEditBatch(() => flashingCells.forEach((flashingCell) => this.clearGridCellFlash(flashingCell)));
41
+ }, duration);
42
+ this.flashClearTimers.add(timer);
43
+ });
14
44
  }
15
45
  addGridCellFlash(flashingCell) {
16
46
  const { rowPrimaryKey } = flashingCell;
@@ -54,10 +84,17 @@ export class FlashingCellService {
54
84
  return Object.keys(this.gridCellsCurrentlyFlashing).length > 0;
55
85
  }
56
86
  refreshGridCells(flashingCell) {
57
- const { cellDataChangedInfo } = flashingCell;
58
- if (!cellDataChangedInfo) {
87
+ const rowNode = flashingCell.cellDataChangedInfo?.rowNode;
88
+ if (!rowNode) {
59
89
  return;
60
90
  }
61
- this.api.gridApi.refreshCells(cellDataChangedInfo.rowNode, Object.keys(flashingCell.flashColumnIds), true);
91
+ const adaptable = this.api.internalApi.getAdaptableInstance();
92
+ const columnIds = Object.keys(flashingCell.flashColumnIds);
93
+ const pinnedSibling = rowNode.pinnedSibling;
94
+ for (const node of pinnedSibling ? [rowNode, pinnedSibling] : [rowNode]) {
95
+ if (adaptable.isRowNodeRendered(node)) {
96
+ this.api.gridApi.refreshCells(node, columnIds, true);
97
+ }
98
+ }
62
99
  }
63
100
  }
@@ -46,6 +46,18 @@ export interface ICalculatedColumnExpressionService extends IAdaptableService {
46
46
  * contains the change — separate from derived `CellDataChanged` events.
47
47
  */
48
48
  getObservableCalculatedColumnsAffectedByColumn(columnId: string): ObservableCalculatedColumnRefresh[];
49
+ /**
50
+ * Aggregated Calculated Columns that read `columnId` (or `ANY_COL()`).
51
+ * Used after a cell change to force-refresh the edited row: the aggregation
52
+ * store only notifies when the scalar or group values move, so a per-row
53
+ * (window) result changing on the edited row would otherwise stay stale.
54
+ */
55
+ getAggregatedCalculatedColumnsAffectedByColumn(columnId: string): string[];
56
+ /**
57
+ * Scalar Calculated Columns whose value depends on `columnId`, directly or through other
58
+ * Calculated Columns; their changes are reported with the `calculatedColumnChange` trigger.
59
+ */
60
+ getDependentScalarCalculatedColumns(columnId: string): CalculatedColumn[];
49
61
  bindAggregatedCalculatedColumn(calculatedColumn: CalculatedColumn): void;
50
62
  unbindAggregatedCalculatedColumn(calculatedColumn: CalculatedColumn): void;
51
63
  buildSyntheticCellDataChangedInfosForCalcColumns(cellDataChangedInfo: CellDataChangedInfo): CellDataChangedInfo[];
@@ -1,7 +1,7 @@
1
1
  import { IAdaptableService } from './IAdaptableService';
2
2
  import { Column } from 'ag-grid-enterprise';
3
3
  import type { AggregationCallableName, AggregationCatalogue, AqlHost, CompiledValueExpression, QueryLanguageValidationResult, ScalarFunctionName, ValueExecutionResult } from "../../../../vendor/aql/index.js";
4
- import type { Clock, ComputedValueStore, HistoryStore } from "../../../../vendor/aql/store/index.js";
4
+ import type { Clock, ComputedValueStore, HistoryStats, HistoryStore } from "../../../../vendor/aql/store/index.js";
5
5
  import type { ExpressionKind, ResolvedExpression } from '../../../AdaptableState/Common/AdaptableQuery';
6
6
  import { CellDataChangedInfo } from '../../../AdaptableState/Common/CellDataChangedInfo';
7
7
  import { AdaptableModule } from '../../../AdaptableState/Common/Types';
@@ -28,6 +28,20 @@ export type QueryLanguageAggregatedComputeContext = {
28
28
  host?: AqlHost;
29
29
  getColumnValue?: (rowRef: unknown, columnId: string) => unknown;
30
30
  };
31
+ export type QueryLanguageServiceDiagnostics = {
32
+ validationCache: number;
33
+ expressionKindCache: number;
34
+ dependenciesCache: number;
35
+ engineCache: number;
36
+ rowEvaluatorCache: number;
37
+ rowEvaluatorCacheLimit: number;
38
+ /** Prepared evaluators dropped because the cache was full (each is prepared again when next used) */
39
+ rowEvaluatorEvictions: number;
40
+ canonicalTextCache: number;
41
+ canonicalTextCacheLimit: number;
42
+ /** `undefined` while no observable expression created the history store */
43
+ history?: HistoryStats;
44
+ };
31
45
  export interface IQueryLanguageService extends IAdaptableService {
32
46
  /**
33
47
  * Infers the evaluation kind of an expression from its text:
@@ -119,6 +133,8 @@ export interface IQueryLanguageService extends IAdaptableService {
119
133
  * `expressionOptions.maxTimeframeSize` / `maxHistoryPerCell`.
120
134
  */
121
135
  getHistoryStore(): HistoryStore;
136
+ /** Cache sizes and history-store counters (AdapTable DevTools memory inventory) */
137
+ getDiagnostics(): QueryLanguageServiceDiagnostics;
122
138
  /**
123
139
  * What an expression's value depends on: aggregations, the row, per-cell
124
140
  * history (`observable`), window expiry (`windowed`) or the clock (`time`).
@@ -126,6 +142,11 @@ export interface IQueryLanguageService extends IAdaptableService {
126
142
  * `(module, expression)` with the other per-expression caches.
127
143
  */
128
144
  getExpressionDependencies(expression: string, module: AdaptableModule): CompiledValueExpression['dependencies'] | undefined;
145
+ /**
146
+ * Changes whenever the expression function pools are refreshed; results derived from
147
+ * expression dependencies can be cached against it
148
+ */
149
+ getFunctionsGeneration(): number;
129
150
  /**
130
151
  * Static result type of an expression (`'number' | 'text' | 'date' |
131
152
  * 'boolean' | 'array' | 'duration'`), from the compiled plan — no