@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
@@ -3,7 +3,7 @@ import { type Clock, type ComputedValueStore, type HistoryStore } from "../../..
3
3
  import { AdaptableApi, AggregatedExpressionEvaluationValue } from '../../../types';
4
4
  import { type ExpressionKind, type ResolvedExpression } from '../../AdaptableState/Common/AdaptableQuery';
5
5
  import { AdaptableModule } from '../../AdaptableState/Common/Types';
6
- import { IQueryLanguageService, ModuleExpressionFunctionsMap, QueryLanguageAggregatedComputeContext, QueryLanguageRowEvalContext } from './Interface/IQueryLanguageService';
6
+ import { IQueryLanguageService, ModuleExpressionFunctionsMap, QueryLanguageAggregatedComputeContext, QueryLanguageRowEvalContext, QueryLanguageServiceDiagnostics } from './Interface/IQueryLanguageService';
7
7
  export declare class QueryLanguageService implements IQueryLanguageService {
8
8
  private adaptableApi;
9
9
  private validationCache;
@@ -13,6 +13,8 @@ export declare class QueryLanguageService implements IQueryLanguageService {
13
13
  private engineCache;
14
14
  private hostEngineCache;
15
15
  private rowEvaluatorCache;
16
+ /** For DevTools: how often the cache above was full (see `getDiagnostics`) */
17
+ private rowEvaluatorEvictions;
16
18
  private hostRowEvaluatorCache;
17
19
  private canonicalTextCache;
18
20
  private functionsGeneration;
@@ -21,12 +23,20 @@ export declare class QueryLanguageService implements IQueryLanguageService {
21
23
  private _historyStore?;
22
24
  private _computedValueStore?;
23
25
  private dependenciesCache;
26
+ /** functions cache key -> expression text -> summary, for `summaryByExpressionTextGeneration` */
27
+ private summaryByExpressionText;
28
+ private summaryByExpressionTextGeneration;
24
29
  /** History-series releases per cached prepared evaluator (see `retainObservableSeries`). */
25
30
  private observableSeriesReleases;
26
31
  private hostEventsBound;
27
32
  private hostEventUnsubscribers;
28
33
  constructor(adaptableApi: AdaptableApi);
29
34
  destroy(): void;
35
+ /**
36
+ * Cache sizes and history-store counters for AdapTable DevTools (memory inventory).
37
+ * Does not create the history store when nothing uses it yet.
38
+ */
39
+ getDiagnostics(): QueryLanguageServiceDiagnostics;
30
40
  /**
31
41
  * Cache/store key text: greenfield pretty-print (stored text is already
32
42
  * migrated). Memoized — canonicalization is a raw parse + normalize +
@@ -127,9 +137,14 @@ export declare class QueryLanguageService implements IQueryLanguageService {
127
137
  private getHostRowEvaluatorCache;
128
138
  private getFirstRowRef;
129
139
  evaluateBooleanExpression(expression: string, module: AdaptableModule, rowNode: any, evalContext?: QueryLanguageRowEvalContext): any;
140
+ private perfAdaptableId?;
141
+ /** Read once: the hot path must not call the options API on every evaluation */
142
+ private getAdaptableIdForPerf;
130
143
  evaluateScalarExpression(expression: string, module: AdaptableModule, rowNode: unknown, evalContext?: QueryLanguageRowEvalContext): any;
131
144
  prepareBooleanRowEvaluator(expression: string, module: AdaptableModule): (rowNode: unknown) => any;
132
145
  executeValueExpression(expression: string, module: AdaptableModule, evalContext?: QueryLanguageRowEvalContext): ValueExecutionResult;
146
+ /** Changes whenever the expression function pools are refreshed */
147
+ getFunctionsGeneration(): number;
133
148
  getExpressionDependencies(expression: string, module: AdaptableModule): CompiledValueExpression['dependencies'] | undefined;
134
149
  getExpressionOutputType(expression: string, module: AdaptableModule): CompiledValueExpression['outputType'];
135
150
  isExpressionRowIndependent(expression: string, module: AdaptableModule): boolean;
@@ -138,6 +153,7 @@ export declare class QueryLanguageService implements IQueryLanguageService {
138
153
  * dependency and the static-type questions; the plan itself is not kept.
139
154
  */
140
155
  private getCompiledExpressionSummary;
156
+ private rememberSummaryForText;
141
157
  isAggregatedBooleanSatisfied(compiled: CompiledValueExpression, result: ValueExecutionResult, module: AdaptableModule, evalContext?: {
142
158
  host?: AqlHost;
143
159
  }): boolean;
@@ -1,3 +1,5 @@
1
+ import { getPerfRecorder } from '../../devTools/PerfStore';
2
+ import { recordExpressionEvaluation } from '../../devTools/perfInstrumentation';
1
3
  import { acquireObservableSlots, canonicalizeExpression, createAggregationCatalogue, createAqlEngine, DEFAULT_ROW_SET_KIND, ExpressionEvaluationError, findDependencyCycle, getNodesFromExpression, hostGetFirstRowRef, mapDataTypeToStaticType, parse, validateAqlExpression, validateExpressionTypes, } from "../../../vendor/aql/index.js";
2
4
  import { createComputedValueStore, createHistoryStore, createSystemClock, } from "../../../vendor/aql/store/index.js";
3
5
  import { inferExpressionKindFromText, } from '../../AdaptableState/Common/AdaptableQuery';
@@ -54,6 +56,7 @@ export class QueryLanguageService {
54
56
  engineCache = new Map();
55
57
  hostEngineCache = new WeakMap();
56
58
  rowEvaluatorCache = new Map();
59
+ rowEvaluatorEvictions = 0;
57
60
  hostRowEvaluatorCache = new WeakMap();
58
61
  canonicalTextCache = new Map();
59
62
  functionsGeneration = 0;
@@ -62,6 +65,8 @@ export class QueryLanguageService {
62
65
  _historyStore;
63
66
  _computedValueStore;
64
67
  dependenciesCache = new Map();
68
+ summaryByExpressionText = new Map();
69
+ summaryByExpressionTextGeneration = 0;
65
70
  observableSeriesReleases = new Map();
66
71
  hostEventsBound = false;
67
72
  hostEventUnsubscribers = [];
@@ -84,12 +89,27 @@ export class QueryLanguageService {
84
89
  this._historyStore?.destroy();
85
90
  this._historyStore = undefined;
86
91
  this.dependenciesCache.clear();
92
+ this.summaryByExpressionText.clear();
87
93
  this.validationCache.clear();
88
94
  this.expressionKindCache.clear();
89
95
  this.rowEvaluatorCache.clear();
90
96
  this.aggregationCatalogueCache.clear();
91
97
  this.engineCache.clear();
92
98
  }
99
+ getDiagnostics() {
100
+ return {
101
+ validationCache: this.validationCache.size,
102
+ expressionKindCache: this.expressionKindCache.size,
103
+ dependenciesCache: this.dependenciesCache.size,
104
+ engineCache: this.engineCache.size,
105
+ rowEvaluatorCache: this.rowEvaluatorCache.size,
106
+ rowEvaluatorCacheLimit: ROW_EVALUATOR_CACHE_SIZE,
107
+ rowEvaluatorEvictions: this.rowEvaluatorEvictions,
108
+ canonicalTextCache: this.canonicalTextCache.size,
109
+ canonicalTextCacheLimit: CANONICAL_TEXT_CACHE_SIZE,
110
+ history: this._historyStore ? this._historyStore.stats() : undefined,
111
+ };
112
+ }
93
113
  toCacheExpression(expression) {
94
114
  const cached = this.canonicalTextCache.get(expression);
95
115
  if (cached !== undefined) {
@@ -352,6 +372,7 @@ export class QueryLanguageService {
352
372
  const oldestKey = cache.keys().next().value;
353
373
  if (oldestKey !== undefined) {
354
374
  cache.delete(oldestKey);
375
+ this.rowEvaluatorEvictions++;
355
376
  this.releaseObservableSeries(oldestKey);
356
377
  }
357
378
  }
@@ -417,19 +438,46 @@ export class QueryLanguageService {
417
438
  this.adaptableApi.logError('QueryLanguageService.evaluateBooleanExpression was called with an undefined expression');
418
439
  return false;
419
440
  }
420
- return this.getPreparedRowEvaluator(expression, module, evalContext?.host)(rowNode, this.toPerRowConfig({
441
+ const recorder = getPerfRecorder(this.getAdaptableIdForPerf());
442
+ const start = recorder ? performance.now() : 0;
443
+ const result = this.getPreparedRowEvaluator(expression, module, evalContext?.host)(rowNode, this.toPerRowConfig({
421
444
  rowNode,
422
445
  dataChangedEvent: evalContext?.dataChangedEvent,
423
446
  pivotResultColumn: evalContext?.pivotResultColumn,
424
447
  columnScope: evalContext?.columnScope,
425
448
  cellValueOverride: evalContext?.cellValueOverride,
426
449
  }));
450
+ if (recorder) {
451
+ recordExpressionEvaluation(recorder, this.adaptableApi, module, expression, start);
452
+ }
453
+ return result;
454
+ }
455
+ perfAdaptableId;
456
+ getAdaptableIdForPerf() {
457
+ if (this.perfAdaptableId === undefined) {
458
+ try {
459
+ this.perfAdaptableId = this.adaptableApi.optionsApi.getAdaptableId();
460
+ }
461
+ catch {
462
+ return undefined;
463
+ }
464
+ }
465
+ return this.perfAdaptableId;
427
466
  }
428
467
  evaluateScalarExpression(expression, module, rowNode, evalContext) {
429
468
  return this.evaluateBooleanExpression(expression, module, rowNode, evalContext);
430
469
  }
431
470
  prepareBooleanRowEvaluator(expression, module) {
432
471
  const evaluator = this.getPreparedRowEvaluator(expression, module);
472
+ const recorder = getPerfRecorder(this.getAdaptableIdForPerf());
473
+ if (recorder) {
474
+ return (rowNode) => {
475
+ const start = performance.now();
476
+ const result = evaluator(rowNode);
477
+ recordExpressionEvaluation(recorder, this.adaptableApi, module, expression, start);
478
+ return result;
479
+ };
480
+ }
433
481
  return (rowNode) => evaluator(rowNode);
434
482
  }
435
483
  executeValueExpression(expression, module, evalContext) {
@@ -441,6 +489,9 @@ export class QueryLanguageService {
441
489
  getRowNodes: evalContext?.getRowNodes,
442
490
  }), { getValue: evalContext?.getColumnValue });
443
491
  }
492
+ getFunctionsGeneration() {
493
+ return this.functionsGeneration;
494
+ }
444
495
  getExpressionDependencies(expression, module) {
445
496
  return this.getCompiledExpressionSummary(expression, module)?.dependencies;
446
497
  }
@@ -454,9 +505,24 @@ export class QueryLanguageService {
454
505
  if (!expression?.trim()) {
455
506
  return undefined;
456
507
  }
457
- const cacheKey = `${this.functionsGeneration}::${this.getExpressionFunctionsCacheKey(module)}::${this.toCacheExpression(expression)}`;
508
+ if (this.summaryByExpressionTextGeneration !== this.functionsGeneration) {
509
+ this.summaryByExpressionText.clear();
510
+ this.summaryByExpressionTextGeneration = this.functionsGeneration;
511
+ }
512
+ const functionsCacheKey = this.getExpressionFunctionsCacheKey(module);
513
+ let summaryByText = this.summaryByExpressionText.get(functionsCacheKey);
514
+ if (!summaryByText) {
515
+ summaryByText = new Map();
516
+ this.summaryByExpressionText.set(functionsCacheKey, summaryByText);
517
+ }
518
+ const cachedForText = summaryByText.get(expression);
519
+ if (cachedForText !== undefined) {
520
+ return cachedForText ?? undefined;
521
+ }
522
+ const cacheKey = `${this.functionsGeneration}::${functionsCacheKey}::${this.toCacheExpression(expression)}`;
458
523
  const cached = this.dependenciesCache.get(cacheKey);
459
524
  if (cached !== undefined) {
525
+ this.rememberSummaryForText(summaryByText, expression, cached);
460
526
  return cached ?? undefined;
461
527
  }
462
528
  let summary;
@@ -472,8 +538,15 @@ export class QueryLanguageService {
472
538
  summary = null;
473
539
  }
474
540
  this.dependenciesCache.set(cacheKey, summary);
541
+ this.rememberSummaryForText(summaryByText, expression, summary);
475
542
  return summary ?? undefined;
476
543
  }
544
+ rememberSummaryForText(summaryByText, expression, summary) {
545
+ if (summaryByText.size >= CANONICAL_TEXT_CACHE_SIZE) {
546
+ summaryByText.clear();
547
+ }
548
+ summaryByText.set(expression, summary);
549
+ }
477
550
  isAggregatedBooleanSatisfied(compiled, result, module, evalContext) {
478
551
  return this.createEngine(module, evalContext?.host).isAggregatedBooleanSatisfied(compiled, result);
479
552
  }
@@ -1,4 +1,5 @@
1
1
  import { AdaptableApi, TableLayout } from '../../types';
2
+ import type { RowSummariesSkippedReason } from '../../Api/Internal/LayoutInternalApi';
2
3
  /**
3
4
  * Row Summary cells are computed-value store nodes with an explicit
4
5
  * rowSetSpec (`visible` when IncludeOnlyFilteredRows, else `all`).
@@ -9,6 +10,7 @@ export declare class RowSummaryService {
9
10
  private nodeHandles;
10
11
  private isEvaluating;
11
12
  previousRowSummaries: any;
13
+ previousSkippedReason: RowSummariesSkippedReason | undefined;
12
14
  previousLayout: TableLayout | null;
13
15
  constructor(api: AdaptableApi);
14
16
  onAdaptableReady(): void;
@@ -9,6 +9,7 @@ export class RowSummaryService {
9
9
  nodeHandles = new Map();
10
10
  isEvaluating = false;
11
11
  previousRowSummaries;
12
+ previousSkippedReason;
12
13
  previousLayout;
13
14
  constructor(api) {
14
15
  this.api = api;
@@ -144,10 +145,14 @@ export class RowSummaryService {
144
145
  this.nodeHandles.delete(key);
145
146
  }
146
147
  }
147
- if (this.previousRowSummaries && isEqual(rowSummariesResults, this.previousRowSummaries)) {
148
+ const skippedReason = this.api.layoutApi.internalApi.getRowSummariesSkippedReason(currentLayout);
149
+ if (this.previousRowSummaries &&
150
+ isEqual(rowSummariesResults, this.previousRowSummaries) &&
151
+ skippedReason === this.previousSkippedReason) {
148
152
  return;
149
153
  }
150
154
  this.api.internalApi.dispatchReduxAction(RowSummarySet(rowSummariesResults));
151
155
  this.previousRowSummaries = rowSummariesResults;
156
+ this.previousSkippedReason = skippedReason;
152
157
  }
153
158
  }
@@ -0,0 +1,12 @@
1
+ import type { AdaptableApi } from '../../Api/AdaptableApi';
2
+ import { LicenseStatus } from './licenseStatus';
3
+ /**
4
+ * The licence key an AdapTable instance runs with: a page-wide
5
+ * `ADAPTABLE_LICENSE_KEY` global wins over `AdaptableOptions.licenseKey`.
6
+ */
7
+ export declare function getInstanceLicenseKey(api: AdaptableApi): string | undefined;
8
+ /**
9
+ * What the instance's licence key means for this AdapTable version. Safe to display
10
+ * and to send to AdapTable DevTools: it never contains the key.
11
+ */
12
+ export declare function getInstanceLicenseStatus(api: AdaptableApi): LicenseStatus;
@@ -0,0 +1,10 @@
1
+ import { ADAPTABLE_PUBLISH_DATE } from '../../EnvVars';
2
+ import { getLicenseStatus } from './licenseStatus';
3
+ export function getInstanceLicenseKey(api) {
4
+ const globalObject = typeof globalThis !== 'undefined' ? globalThis : window;
5
+ return (globalObject.ADAPTABLE_LICENSE_KEY ||
6
+ api.optionsApi.getLicenseKey());
7
+ }
8
+ export function getInstanceLicenseStatus(api) {
9
+ return getLicenseStatus(getInstanceLicenseKey(api), ADAPTABLE_PUBLISH_DATE);
10
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What a licence key means, without any of its content: shown in place of the key
3
+ * in Grid Info and AdapTable DevTools.
4
+ */
5
+ export type LicenseStatus = {
6
+ kind: 'none';
7
+ } | {
8
+ kind: 'invalid';
9
+ } | {
10
+ kind: 'valid' | 'expired';
11
+ trial: boolean;
12
+ /** Licence end date, `yyyy-mm-dd` */
13
+ endDate: string;
14
+ /** Whole days left (`valid`) or since expiry (`expired`) */
15
+ days: number;
16
+ /**
17
+ * `expired` only: whether this AdapTable version was released before the licence
18
+ * expired. Omitted when the release date is unknown.
19
+ *
20
+ * Only a commercial licence keeps working for the versions it covers; an expired
21
+ * trial is restricted either way.
22
+ */
23
+ coversThisVersion?: boolean;
24
+ };
25
+ export declare function getLicenseStatus(licenseKey: string | undefined, publishedAt?: number | Date, now?: Date): LicenseStatus;
26
+ export declare function formatLicenseStatus(status: LicenseStatus): string;
@@ -0,0 +1,72 @@
1
+ import { decode } from './decode';
2
+ const DAY_IN_MS = 1000 * 60 * 60 * 24;
3
+ function toDateString(date) {
4
+ const pad = (value) => String(value).padStart(2, '0');
5
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
6
+ }
7
+ function calendarDaysBetween(from, to) {
8
+ const fromMidnight = new Date(from);
9
+ fromMidnight.setHours(0, 0, 0, 0);
10
+ const toMidnight = new Date(to);
11
+ toMidnight.setHours(0, 0, 0, 0);
12
+ return Math.round((toMidnight.getTime() - fromMidnight.getTime()) / DAY_IN_MS);
13
+ }
14
+ export function getLicenseStatus(licenseKey, publishedAt, now = new Date()) {
15
+ if (!licenseKey) {
16
+ return { kind: 'none' };
17
+ }
18
+ let end;
19
+ let trial;
20
+ try {
21
+ ({ end, trial } = decode(licenseKey));
22
+ }
23
+ catch {
24
+ return { kind: 'invalid' };
25
+ }
26
+ if (Number.isNaN(end.getTime())) {
27
+ return { kind: 'invalid' };
28
+ }
29
+ const endDate = toDateString(end);
30
+ const days = Math.abs(calendarDaysBetween(now, end));
31
+ if (end >= now) {
32
+ return { kind: 'valid', trial, endDate, days };
33
+ }
34
+ const status = { kind: 'expired', trial, endDate, days };
35
+ if (publishedAt != null) {
36
+ status.coversThisVersion = end > new Date(publishedAt);
37
+ }
38
+ return status;
39
+ }
40
+ function formatDate(endDate) {
41
+ const [year, month, day] = endDate.split('-').map(Number);
42
+ return new Date(year, month - 1, day).toLocaleDateString('en-GB', {
43
+ day: 'numeric',
44
+ month: 'short',
45
+ year: 'numeric',
46
+ });
47
+ }
48
+ function pluralDays(days) {
49
+ return days === 1 ? '1 day' : `${days} days`;
50
+ }
51
+ export function formatLicenseStatus(status) {
52
+ if (status.kind === 'none') {
53
+ return 'Not present';
54
+ }
55
+ if (status.kind === 'invalid') {
56
+ return 'Invalid';
57
+ }
58
+ const type = status.trial ? 'Trial' : 'Commercial';
59
+ const date = formatDate(status.endDate);
60
+ if (status.kind === 'valid') {
61
+ const left = status.days === 0 ? 'expires today' : `${pluralDays(status.days)} left`;
62
+ return `${type}, valid until ${date} (${left})`;
63
+ }
64
+ const ago = status.days === 0 ? 'today' : `${pluralDays(status.days)} ago`;
65
+ const text = `${type}, expired on ${date} (${ago})`;
66
+ if (status.trial || status.coversThisVersion == null) {
67
+ return text;
68
+ }
69
+ return status.coversThisVersion
70
+ ? `${text}; covers this AdapTable version`
71
+ : `${text}; does not cover this AdapTable version (released after expiry)`;
72
+ }
@@ -32,12 +32,18 @@ const DEFAULT_ROW_ALIGN_POSITION = [
32
32
  ['TopCenter', 'BottomCenter'],
33
33
  ['BottomCenter', 'TopCenter'],
34
34
  ];
35
- function resolveRowAnchorElement(primaryKeyValue) {
36
- const centerRow = document.querySelector(`.ag-center-cols-container [row-id="${primaryKeyValue}"]`);
37
- if (centerRow) {
38
- return centerRow;
35
+ const escapeAttributeValue = (value) => {
36
+ const text = String(value);
37
+ return typeof CSS !== 'undefined' && typeof CSS.escape === 'function'
38
+ ? CSS.escape(text)
39
+ : text.replace(/["\\]/g, '\\$&');
40
+ };
41
+ function queryGridElement(gridRoot, selector) {
42
+ const ownRootWrapper = gridRoot?.querySelector('.ag-root-wrapper');
43
+ if (!ownRootWrapper) {
44
+ return document.querySelector(selector);
39
45
  }
40
- return document.querySelector(`[row-id="${primaryKeyValue}"]`);
46
+ return (Array.from(ownRootWrapper.querySelectorAll(selector)).find((element) => element.closest('.ag-root-wrapper') === ownRootWrapper) ?? null);
41
47
  }
42
48
  export const CellPopup = React.forwardRef((props, ref) => {
43
49
  ensurePortalElement(props.className);
@@ -47,11 +53,10 @@ export const CellPopup = React.forwardRef((props, ref) => {
47
53
  });
48
54
  const OVERLAY_ID = 'cell-overlay';
49
55
  const showCellPopupContent = () => {
50
- const cellSelector = `[row-id="${props.primaryKeyValue}"] [col-id="${props.columnId}"]`;
51
- const alignTo = props.anchor === 'row'
52
- ? resolveRowAnchorElement(props.primaryKeyValue) ??
53
- document.querySelector(cellSelector)
54
- : document.querySelector(cellSelector);
56
+ const gridRoot = adaptable.agGridAdapter.getAgGridRootElement();
57
+ const rowSelector = `.ag-row[row-id="${escapeAttributeValue(props.primaryKeyValue)}"]`;
58
+ const cellSelector = `${rowSelector} .ag-cell[col-id="${escapeAttributeValue(props.columnId)}"]`;
59
+ const alignTo = queryGridElement(gridRoot, props.anchor === 'row' ? rowSelector : cellSelector);
55
60
  if (!alignTo) {
56
61
  adaptable.logger.consoleError(`Cell not found for selector "${cellSelector}". Unable to display popup.`);
57
62
  return;
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
3
3
  import { ADAPTABLE_VERSION } from '../../EnvVars';
4
+ import { formatLicenseStatus } from '../../Utilities/license/licenseStatus';
5
+ import { getInstanceLicenseStatus } from '../../Utilities/license/instanceLicense';
4
6
  import { AG_GRID_VERSION } from '../../agGrid/AgGridModulesAdapter';
5
7
  import { DataSource, InfiniteTableGrid } from '../../components/InfiniteTable';
6
8
  import Panel from '../../components/Panel';
@@ -39,7 +41,10 @@ export const GridInfoPopup = (props) => {
39
41
  if (api.optionsApi.getUserInterfaceOptions()?.showAgGridVersion) {
40
42
  summaryKeyValuePairs.push({ Key: 'AG Grid Version', Value: agGridVersion });
41
43
  }
42
- summaryKeyValuePairs.push({ Key: 'License Key', Value: api.optionsApi.getAdaptableOptions().licenseKey });
44
+ summaryKeyValuePairs.push({
45
+ Key: 'License',
46
+ Value: formatLicenseStatus(getInstanceLicenseStatus(api)),
47
+ });
43
48
  summaryKeyValuePairs.push({ Key: 'Adaptable Id', Value: api.optionsApi.getAdaptableId() });
44
49
  summaryKeyValuePairs.push({ Key: 'State Key', Value: api.optionsApi.getAdaptableStateKey() });
45
50
  summaryKeyValuePairs.push({ Key: 'User Name', Value: api.optionsApi.getUserName() });
@@ -71,6 +71,7 @@ function buildTransposedGridOptions({ transposedRowsAndColumns, elevatedColumnId
71
71
  ...transposedRowsAndColumns.transposedColumns.map((col) => ({ field: col.colId, headerName: col.header })),
72
72
  ],
73
73
  rowData: transposedRowsAndColumns.transposedRows,
74
+ getRowId: (params) => params.data[TRANSPOSED_FIRST_COLUMN_FIELD],
74
75
  sideBar: false,
75
76
  };
76
77
  }
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { Layout, TableLayout } from '../../../../../types';
3
3
  import { AggregationColumnValue } from '../../../../AdaptableState/Common/AggregationColumns';
4
- export type GrandTotalRowPosition = 'top' | 'bottom' | 'pinnedTop' | 'pinnedBottom';
5
- export declare const GRAND_TOTAL_ROW_LABELS: Record<GrandTotalRowPosition | 'off', string>;
4
+ import { GRAND_TOTAL_ROW_LABELS, GrandTotalRowPosition, getGrandTotalRowKey, getGrandTotalRowLabel } from '../../../../View/ObjectItemViews/Layout/aggregationSummaryHelpers';
5
+ export { GRAND_TOTAL_ROW_LABELS, getGrandTotalRowKey, getGrandTotalRowLabel };
6
+ export type { GrandTotalRowPosition };
6
7
  export declare const GRAND_TOTAL_ROW_DESCRIPTIONS: Record<GrandTotalRowPosition | 'off', string>;
7
8
  export declare const GRAND_TOTAL_ROW_OPTIONS: (GrandTotalRowPosition | 'off')[];
8
- export declare function getGrandTotalRowKey(layout: Layout): GrandTotalRowPosition | 'off';
9
- export declare function getGrandTotalRowLabel(layout: Layout): string;
10
9
  export declare function getGrandTotalRowDescription(layout: Layout): string;
11
10
  export declare function getAggFuncSummaryLabel(columnId: string, aggFunc: AggregationColumnValue, aggregationColumnsMap: Record<string, string>): string;
12
11
  export declare const isAggregationsSectionValid: (data: Layout) => true | string;
@@ -18,4 +17,3 @@ interface AggregationsSectionProps {
18
17
  layoutWizardMode?: 'create' | 'edit';
19
18
  }
20
19
  export declare const AggregationsSection: React.FunctionComponent<AggregationsSectionProps>;
21
- export {};
@@ -15,17 +15,12 @@ import { Box, Flex } from '../../../../components/Flex';
15
15
  import { SingleSelect } from '../../../../components/Select';
16
16
  import { LAYOUT_WIZARD_COLUMN_LIST_HEADER_CLASS, LAYOUT_WIZARD_COLUMN_LIST_OPTION_CLASS, LAYOUT_WIZARD_COLUMN_LIST_SEARCH_CLASS, } from '../../Utilities/layoutWizardColumns';
17
17
  import Radio, { RadioGroup } from '../../../../components/Radio';
18
+ import HelpBlock from '../../../../components/HelpBlock';
18
19
  import { TypeRadio } from '../../../Wizard/TypeRadio';
19
- import { getTableAggregationSummaryValues } from '../../../../View/ObjectItemViews/Layout/aggregationSummaryHelpers';
20
+ import { GRAND_TOTAL_ROW_LABELS, getGrandTotalRowKey, getGrandTotalRowLabel, getTableAggregationSummaryValues, } from '../../../../View/ObjectItemViews/Layout/aggregationSummaryHelpers';
20
21
  import { renderSummaryStringTags } from '../../../Wizard/SummaryColorTag';
21
22
  const WEIGHTED_AVERAGE_AGG_FN_NAME = 'weightedAvg';
22
- export const GRAND_TOTAL_ROW_LABELS = {
23
- off: 'None',
24
- top: 'Top',
25
- bottom: 'Bottom',
26
- pinnedTop: 'Pinned Top',
27
- pinnedBottom: 'Pinned Bottom',
28
- };
23
+ export { GRAND_TOTAL_ROW_LABELS, getGrandTotalRowKey, getGrandTotalRowLabel };
29
24
  export const GRAND_TOTAL_ROW_DESCRIPTIONS = {
30
25
  off: 'Grand Total Row is not displayed in the grid',
31
26
  top: 'Grand Total Row is displayed at the top of the grid',
@@ -40,16 +35,6 @@ export const GRAND_TOTAL_ROW_OPTIONS = [
40
35
  'pinnedTop',
41
36
  'pinnedBottom',
42
37
  ];
43
- export function getGrandTotalRowKey(layout) {
44
- const value = layout.GrandTotalRow;
45
- if (value == null || value === false) {
46
- return 'off';
47
- }
48
- return value;
49
- }
50
- export function getGrandTotalRowLabel(layout) {
51
- return GRAND_TOTAL_ROW_LABELS[getGrandTotalRowKey(layout)];
52
- }
53
38
  export function getGrandTotalRowDescription(layout) {
54
39
  return GRAND_TOTAL_ROW_DESCRIPTIONS[getGrandTotalRowKey(layout)];
55
40
  }
@@ -161,6 +146,7 @@ export const AggregationsSection = (props) => {
161
146
  const allAggregableColumns = adaptable.api.columnApi.getAggregatableColumns();
162
147
  const allColumns = adaptable.api.columnApi.getUIAvailableColumns();
163
148
  const numberColumns = adaptable.api.columnApi.getNumericColumns();
149
+ const hasActiveRowSummaries = (layout.RowSummaries ?? []).some((rowSummary) => !rowSummary.IsSuspended);
164
150
  const allAggregatableColumnIds = allAggregableColumns.map((col) => col.columnId);
165
151
  (layout.TableAggregationColumns || []).forEach((agg) => {
166
152
  if (!allAggregatableColumnIds.includes(agg.ColumnId)) {
@@ -226,10 +212,10 @@ export const AggregationsSection = (props) => {
226
212
  ? 'Hide Function Name in Header'
227
213
  : 'Show Function Name in Header' }), summary: _jsx(CollapsibleWizardValueSummary, { value: _jsx(Tag, { children: layout.SuppressAggFuncInHeader
228
214
  ? 'Hide Function Name in Header'
229
- : 'Show Function Name in Header' }) }), children: _jsxs(RadioGroup, { orientation: "vertical", value: layout.SuppressAggFuncInHeader ?? false, onRadioChange: handleSuppressAggFuncInHeader, children: [_jsx(Radio, { value: false, children: "Show Aggregation function names" }), _jsx(Radio, { value: true, children: "Hide Aggregation function names" })] }) }), _jsx(CollapsibleWizardCard, { ...bindCard('grand-total'), surface: "panel", "data-name": "grand-total-row", title: "Grand Total Row", help: "Set position of the Grand Total Row in the grid", collapsedHelp: "Position of the Grand Total Row in the grid", compactSummary: _jsx(Tag, { children: getGrandTotalRowLabel(layout) }), summary: _jsx(CollapsibleWizardValueSummary, { value: _jsx(Tag, { children: getGrandTotalRowLabel(layout) }) }), children: _jsx(RadioGroup, { orientation: "vertical", value: getGrandTotalRowKey(layout), onRadioChange: (key) => {
230
- props.onChange({
231
- ...layout,
232
- GrandTotalRow: key === 'off' ? null : key,
233
- });
234
- }, children: GRAND_TOTAL_ROW_OPTIONS.map((key) => (_jsx(TypeRadio, { value: key, text: GRAND_TOTAL_ROW_LABELS[key], description: GRAND_TOTAL_ROW_DESCRIPTIONS[key] }, key))) }) })] }));
215
+ : 'Show Function Name in Header' }) }), children: _jsxs(RadioGroup, { orientation: "vertical", value: layout.SuppressAggFuncInHeader ?? false, onRadioChange: handleSuppressAggFuncInHeader, children: [_jsx(Radio, { value: false, children: "Show Aggregation function names" }), _jsx(Radio, { value: true, children: "Hide Aggregation function names" })] }) }), _jsxs(CollapsibleWizardCard, { ...bindCard('grand-total'), surface: "panel", "data-name": "grand-total-row", title: "Grand Total Row", help: "Set position of the Grand Total Row in the grid", collapsedHelp: "Position of the Grand Total Row in the grid", compactSummary: _jsx(Tag, { children: getGrandTotalRowLabel(layout) }), summary: _jsx(CollapsibleWizardValueSummary, { value: _jsx(Tag, { children: getGrandTotalRowLabel(layout) }) }), children: [_jsx(RadioGroup, { orientation: "vertical", value: getGrandTotalRowKey(layout), onRadioChange: (key) => {
216
+ props.onChange({
217
+ ...layout,
218
+ GrandTotalRow: key === 'off' ? null : key,
219
+ });
220
+ }, children: GRAND_TOTAL_ROW_OPTIONS.map((key) => (_jsx(TypeRadio, { value: key, text: GRAND_TOTAL_ROW_LABELS[key], description: GRAND_TOTAL_ROW_DESCRIPTIONS[key] }, key))) }), hasActiveRowSummaries && (_jsx(HelpBlock, { "data-name": "grand-total-row-summaries-note", className: "twa:mt-2", children: "The Row Summaries of this Layout are not displayed when the Grand Total Row is Pinned Top or Pinned Bottom" }))] })] }));
235
221
  };
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import * as React from 'react';
3
3
  import { CheckBox } from '../../../../components/CheckBox';
4
4
  import FormLayout, { FormRow } from '../../../../components/FormLayout';
5
+ import HelpBlock from '../../../../components/HelpBlock';
5
6
  import SimpleButton from '../../../../components/SimpleButton';
6
7
  import { ButtonNew } from '../../../Components/Buttons/ButtonNew';
7
8
  import { Card } from '../../../../components/Card';
@@ -194,6 +195,7 @@ export const RowSummarySection = (props) => {
194
195
  const adaptable = useAdaptable();
195
196
  const { data: layout } = useOnePageAdaptableWizardContext();
196
197
  const rowSummaries = layout.RowSummaries ?? [];
198
+ const skippedReason = adaptable.api.layoutApi.internalApi.getRowSummariesSkippedReason(layout);
197
199
  const availableScalarExpressions = React.useMemo(() => {
198
200
  const sytemExpressions = adaptable.api.internalApi
199
201
  .getQueryLanguageService()
@@ -235,7 +237,9 @@ export const RowSummarySection = (props) => {
235
237
  }
236
238
  }
237
239
  };
238
- return (_jsxs(Box, { className: cn(getWizardAccordionSectionClassName(hasExpandedCard, expandedFillsSpace), 'twa:p-3'), children: [_jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:mb-2 twa:max-w-[520px] twa:shrink-0", children: "Add summary rows at the top or bottom of the grid with aggregated column values" }), _jsx(Flex, { className: "twa:justify-end twa:mb-2 twa:shrink-0", children: _jsx(ButtonNew, { onClick: handleAddRowSummary, children: "Add Row Summary" }) }), _jsx(Flex, { flexDirection: "column", className: "twa:gap-3 twa:min-h-0 twa:flex-1 twa:overflow-y-auto", children: rowSummaries.map((rowSummary, index) => {
240
+ return (_jsxs(Box, { className: cn(getWizardAccordionSectionClassName(hasExpandedCard, expandedFillsSpace), 'twa:p-3'), children: [_jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:mb-2 twa:max-w-[520px] twa:shrink-0", children: "Add summary rows at the top or bottom of the grid with aggregated column values" }), skippedReason && (_jsx(HelpBlock, { "data-name": "row-summaries-not-displayed", className: "twa:mb-2 twa:shrink-0", children: skippedReason === 'rowPinning'
241
+ ? 'Row Summaries are not displayed, because Row Pinning is enabled in the grid'
242
+ : 'Row Summaries are not displayed while the Grand Total Row is pinned; choose Top or Bottom for the Grand Total Row in the Aggregations section to display them' })), _jsx(Flex, { className: "twa:justify-end twa:mb-2 twa:shrink-0", children: _jsx(ButtonNew, { onClick: handleAddRowSummary, children: "Add Row Summary" }) }), _jsx(Flex, { flexDirection: "column", className: "twa:gap-3 twa:min-h-0 twa:flex-1 twa:overflow-y-auto", children: rowSummaries.map((rowSummary, index) => {
239
243
  const cardBinding = bindCard(rowSummaryCardId(index), { fillAvailable: true });
240
244
  return (_jsx(CollapsibleWizardCard, { ...cardBinding, surface: "panel", "data-name": `row-summary-${index}`, title: `Row Summary ${index + 1}`, help: "Configure position, filters, and column aggregations for this summary row", collapsedHelp: false, compactSummary: _jsx(RowSummaryPositionTag, { position: rowSummary.Position }), headerVisual: !cardBinding.expanded ? (_jsx(RowSummaryPositionTag, { position: rowSummary.Position })) : undefined, headerActions: _jsxs(_Fragment, { children: [cardBinding.expanded ? (_jsx(SuspendToggleButton, { className: objectListActionButtonClassName('suspend'), onSuspend: () => {
241
245
  const newSummaries = [...rowSummaries];
@@ -1,4 +1,8 @@
1
- import { AdaptableApi, PivotLayout, TableLayout } from '../../../types';
1
+ import { AdaptableApi, LayoutBase, PivotLayout, TableLayout } from '../../../types';
2
+ export type GrandTotalRowPosition = 'top' | 'bottom' | 'pinnedTop' | 'pinnedBottom';
3
+ export declare const GRAND_TOTAL_ROW_LABELS: Record<GrandTotalRowPosition | 'off', string>;
4
+ export declare function getGrandTotalRowKey(layout: LayoutBase): GrandTotalRowPosition | 'off';
5
+ export declare function getGrandTotalRowLabel(layout: LayoutBase): string;
2
6
  export declare function getTableAggregationSummaryValues(layout: TableLayout, api: AdaptableApi): string[];
3
7
  export declare function getPivotAggregationSummaryValues(layout: PivotLayout, api: AdaptableApi): string[];
4
8
  export declare function getLayoutTableAggregationViewItems(layout: TableLayout, api: AdaptableApi): {
@@ -1,6 +1,6 @@
1
1
  import { WEIGHTED_AVERAGE_AGG_FN_NAME } from '../../../AdaptableState/Common/AggregationColumns';
2
2
  const IGNORED_AGG_COLUMN_IDS = new Set(['Source', 'Uuid', 'AdaptableVersion']);
3
- const GRAND_TOTAL_ROW_LABELS = {
3
+ export const GRAND_TOTAL_ROW_LABELS = {
4
4
  off: 'None',
5
5
  top: 'Top',
6
6
  bottom: 'Bottom',
@@ -12,14 +12,17 @@ const PIVOT_LAYOUT_TOTAL_LABELS = {
12
12
  before: 'Before',
13
13
  after: 'After',
14
14
  };
15
- function getGrandTotalRowKey(layout) {
15
+ export function getGrandTotalRowKey(layout) {
16
16
  const value = layout.GrandTotalRow;
17
17
  if (value == null || value === false) {
18
18
  return 'off';
19
19
  }
20
+ if (value === true) {
21
+ return 'top';
22
+ }
20
23
  return value;
21
24
  }
22
- function getGrandTotalRowLabel(layout) {
25
+ export function getGrandTotalRowLabel(layout) {
23
26
  return GRAND_TOTAL_ROW_LABELS[getGrandTotalRowKey(layout)];
24
27
  }
25
28
  function getPivotLayoutTotalKey(value) {