@adaptabletools/adaptable 24.0.2 → 24.0.3

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 (104) 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 +6 -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/Implementation/AlertApiImpl.js +2 -0
  12. package/src/Api/Internal/CalculatedColumnInternalApi.js +25 -3
  13. package/src/Api/Internal/ExportInternalApi.d.ts +2 -0
  14. package/src/Api/Internal/ExportInternalApi.js +39 -3
  15. package/src/Api/Internal/LayoutInternalApi.d.ts +11 -1
  16. package/src/Api/Internal/LayoutInternalApi.js +34 -3
  17. package/src/Api/Internal/NoteInternalApi.d.ts +12 -0
  18. package/src/Api/Internal/NoteInternalApi.js +11 -0
  19. package/src/EnvVars.d.ts +1 -0
  20. package/src/EnvVars.js +1 -0
  21. package/src/Redux/Store/AdaptableStore.js +4 -7
  22. package/src/Strategy/FlashingCellModule.js +2 -0
  23. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +1 -0
  24. package/src/Utilities/Services/CalculatedColumnExpressionService.js +15 -0
  25. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +7 -0
  26. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +17 -1
  27. package/src/Utilities/Services/QueryLanguageService.d.ts +11 -1
  28. package/src/Utilities/Services/QueryLanguageService.js +46 -1
  29. package/src/Utilities/Services/RowSummaryService.d.ts +2 -0
  30. package/src/Utilities/Services/RowSummaryService.js +6 -1
  31. package/src/Utilities/license/instanceLicense.d.ts +12 -0
  32. package/src/Utilities/license/instanceLicense.js +10 -0
  33. package/src/Utilities/license/licenseStatus.d.ts +26 -0
  34. package/src/Utilities/license/licenseStatus.js +72 -0
  35. package/src/View/Components/CellPopup/index.js +15 -10
  36. package/src/View/GridInfo/GridInfoPopup.js +6 -1
  37. package/src/View/Layout/TransposedPopup.js +1 -0
  38. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +3 -5
  39. package/src/View/Layout/Wizard/sections/AggregationsSection.js +10 -24
  40. package/src/View/Layout/Wizard/sections/RowSummarySection.js +5 -1
  41. package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.d.ts +5 -1
  42. package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.js +6 -3
  43. package/src/agGrid/AdaptableAgGrid.d.ts +7 -3
  44. package/src/agGrid/AdaptableAgGrid.js +122 -47
  45. package/src/agGrid/AdaptableFilterHandler.d.ts +2 -0
  46. package/src/agGrid/AdaptableFilterHandler.js +34 -0
  47. package/src/agGrid/AgGridAdapter.d.ts +9 -0
  48. package/src/agGrid/AgGridAdapter.js +23 -12
  49. package/src/agGrid/AgGridColumnAdapter.d.ts +2 -0
  50. package/src/agGrid/AgGridColumnAdapter.js +124 -78
  51. package/src/agGrid/AgGridExportAdapter.d.ts +5 -0
  52. package/src/agGrid/AgGridExportAdapter.js +31 -0
  53. package/src/agGrid/AgGridMenuAdapter.js +1 -1
  54. package/src/agGrid/applyGlobalGridOptions.d.ts +9 -0
  55. package/src/agGrid/applyGlobalGridOptions.js +36 -0
  56. package/src/agGrid/cellRenderers/BadgeRenderer.js +22 -0
  57. package/src/agGrid/columnMinMaxCache.d.ts +33 -0
  58. package/src/agGrid/columnMinMaxCache.js +50 -0
  59. package/src/devTools/PerfStore.d.ts +218 -0
  60. package/src/devTools/PerfStore.js +717 -0
  61. package/src/devTools/index.d.ts +33 -0
  62. package/src/devTools/index.js +132 -56
  63. package/src/devTools/logBuffer.d.ts +17 -0
  64. package/src/devTools/logBuffer.js +33 -0
  65. package/src/devTools/memoryInfo.d.ts +15 -0
  66. package/src/devTools/memoryInfo.js +229 -0
  67. package/src/devTools/memoryRoots.d.ts +41 -0
  68. package/src/devTools/memoryRoots.js +136 -0
  69. package/src/devTools/perfContext.d.ts +5 -0
  70. package/src/devTools/perfContext.js +155 -0
  71. package/src/devTools/perfInstrumentation.d.ts +13 -0
  72. package/src/devTools/perfInstrumentation.js +78 -0
  73. package/src/env.js +2 -2
  74. package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -1
  75. package/src/layout-manager/src/expandAllRowGroups.d.ts +6 -0
  76. package/src/layout-manager/src/expandAllRowGroups.js +13 -0
  77. package/src/layout-manager/src/index.js +18 -10
  78. package/src/setupDevTools.js +560 -106
  79. package/tsconfig.esm.tsbuildinfo +1 -1
  80. package/vendor/components/Combobox/index.js +1 -1
  81. package/vendor/components/Combobox/index.js.map +1 -1
  82. package/vendor/components/Radio/index.d.ts.map +1 -1
  83. package/vendor/components/Radio/index.js +1 -1
  84. package/vendor/components/Radio/index.js.map +1 -1
  85. package/vendor/components/Resizable/index.d.ts +14 -9
  86. package/vendor/components/Resizable/index.d.ts.map +1 -1
  87. package/vendor/components/Resizable/index.js +23 -0
  88. package/vendor/components/Resizable/index.js.map +1 -1
  89. package/vendor/components/Resizable/resizableUtils.d.ts +24 -13
  90. package/vendor/components/Resizable/resizableUtils.d.ts.map +1 -1
  91. package/vendor/components/Resizable/resizableUtils.js +13 -3
  92. package/vendor/components/Resizable/resizableUtils.js.map +1 -1
  93. package/vendor/components/index.css +12 -5
  94. package/vendor/components/ui/combobox.js +1 -1
  95. package/vendor/components/ui/combobox.js.map +1 -1
  96. package/vendor/components/ui/input.js +1 -1
  97. package/vendor/components/ui/input.js.map +1 -1
  98. package/vendor/components/ui/select.js +1 -1
  99. package/vendor/components/ui/select.js.map +1 -1
  100. package/vendor/components/ui/textarea.js +1 -1
  101. package/vendor/components/ui/textarea.js.map +1 -1
  102. package/vendor/components/ui/tooltip.d.ts.map +1 -1
  103. package/vendor/components/ui/tooltip.js +3 -1
  104. package/vendor/components/ui/tooltip.js.map +1 -1
@@ -1,3 +1,4 @@
1
+ import { getPerfRecorder } from '../devTools/PerfStore';
1
2
  import { kebabCase } from '../Utilities/Extensions/StringExtensions';
2
3
  import { resolveDisplayFormat } from '../AdaptableState/Common/AdaptableFormatPresets';
3
4
  import { merge } from '../Utilities/Extensions/ObjectExtensions';
@@ -71,6 +72,13 @@ const STABLE_CALLBACK_COL_DEF_PROPERTIES = new Set([
71
72
  'cellEditorParams',
72
73
  'suppressNoteActions',
73
74
  ]);
75
+ const PERF_HOT_PATH_KINDS = {
76
+ cellStyle: 'cellStyle',
77
+ cellClass: 'cellClass',
78
+ valueFormatter: 'valueFormatter',
79
+ comparator: 'comparator',
80
+ getQuickFilterText: 'quickFilterText',
81
+ };
74
82
  export function getEditorForColumnDataType(columnDataType, variant) {
75
83
  if (columnDataType === 'number') {
76
84
  return variant === 'react' ? AdaptableReactNumberEditor : AdaptableNumberEditor;
@@ -175,6 +183,10 @@ export class AgGridColumnAdapter {
175
183
  this.stableCallbackImplementations.set(key, implementation);
176
184
  let stableCallback = this.stableCallbacks.get(key);
177
185
  if (!stableCallback) {
186
+ const perfKind = PERF_HOT_PATH_KINDS[propertyName];
187
+ const perfKey = perfKind ? `${perfKind}:${colId}` : '';
188
+ const describePerf = () => ({ columnId: colId });
189
+ const adaptableId = this.adaptableInstance?.adaptableOptions?.adaptableId;
178
190
  stableCallback = (...args) => {
179
191
  if (!this.adaptableInstance || this.adaptableInstance.isDestroyed) {
180
192
  const userValue = this.colDefPropertyCache?.get(`user.${colId}.${propertyName}`);
@@ -183,7 +195,20 @@ export class AgGridColumnAdapter {
183
195
  }
184
196
  return userValue;
185
197
  }
186
- return this.stableCallbackImplementations?.get(key)?.(...args);
198
+ const implementation = this.stableCallbackImplementations?.get(key);
199
+ if (perfKind && implementation) {
200
+ const recorder = getPerfRecorder(adaptableId);
201
+ if (recorder) {
202
+ const start = performance.now();
203
+ try {
204
+ return implementation(...args);
205
+ }
206
+ finally {
207
+ recorder.add(perfKind, perfKey, start, describePerf);
208
+ }
209
+ }
210
+ }
211
+ return implementation?.(...args);
187
212
  };
188
213
  this.stableCallbacks.set(key, stableCallback);
189
214
  this.stableCallbackOwners.set(stableCallback, { colId, propertyName });
@@ -677,101 +702,122 @@ export class AgGridColumnAdapter {
677
702
  });
678
703
  }
679
704
  setupColumnTooltip({ col, colId, abColumn }) {
680
- let hasTooptip = false;
681
- this.setColDefProperty(col, 'tooltip', () => {
705
+ this.setColDefProperty(col, 'tooltip', (userTooltip) => {
682
706
  const styledColumn = this.adaptableApi.styledColumnApi.getStyledColumnForColumnId(colId);
683
707
  if (!styledColumn || styledColumn.IsSuspended) {
684
708
  return undefined;
685
709
  }
686
- if (styledColumn.IconStyle && !isUnsupportedColumnDataTypeForIconStyle(abColumn.dataType)) {
687
- const iconTokens = styledColumn.IconStyle.ToolTipText ?? [];
688
- if (iconTokens.length === 0) {
689
- return undefined;
690
- }
691
- hasTooptip = true;
692
- return (params) => {
693
- const parts = [];
694
- if (iconTokens.includes('CellValue')) {
695
- parts.push(String(params.value ?? ''));
696
- }
697
- if (iconTokens.includes('IconDescription')) {
698
- const matched = findIconStyleMappingForValue(styledColumn.IconStyle, params.value);
699
- if (matched?.Description) {
700
- parts.push(matched.Description);
701
- }
702
- }
703
- const trimmed = parts.filter(Boolean).join(' · ').trim();
704
- return trimmed ? trimmed : String(params.value ?? '');
705
- };
710
+ const styledColumnTooltip = this.getStyledColumnTooltip(styledColumn, abColumn);
711
+ if (!styledColumnTooltip) {
712
+ return undefined;
706
713
  }
707
- if (styledColumn.RatingStyle) {
708
- const ratingToolTip = styledColumn.RatingStyle.ToolTipText ?? [];
709
- if (ratingToolTip.length === 0) {
710
- return undefined;
714
+ return (params) => {
715
+ if (params.node &&
716
+ !shouldRenderStyledColumnOnRow(styledColumn, params.node, this.adaptableApi)) {
717
+ return this.resolveColDefTooltip(userTooltip, params);
711
718
  }
712
- hasTooptip = true;
713
- const ratingMax = styledColumn.RatingStyle.Max ?? 5;
714
- return (params) => {
715
- let returnValue = '';
716
- if (ratingToolTip.includes('CellValue')) {
717
- returnValue = String(params.value ?? '');
718
- }
719
- if (ratingToolTip.includes('PercentageValue') && ratingMax > 0) {
720
- const n = Number(params.value);
721
- if (!isNaN(n)) {
722
- const clamped = clamp(n, 0, ratingMax);
723
- const percentageValue = (clamped / ratingMax) * 100;
724
- const pct = `${percentageValue.toFixed(0)}%`;
725
- returnValue = returnValue ? `${returnValue} (${pct})` : pct;
726
- }
727
- }
728
- const trimmed = returnValue.trim();
729
- return trimmed ? trimmed : String(params.value ?? '');
730
- };
731
- }
732
- const tooltipStyle = styledColumn.PercentBarStyle ??
733
- styledColumn.BulletChartStyle ??
734
- styledColumn.GradientStyle ??
735
- styledColumn.RangeBarStyle;
736
- const textOptions = tooltipStyle?.ToolTipText;
737
- if (!tooltipStyle || !textOptions || textOptions.length === 0) {
719
+ return styledColumnTooltip(params);
720
+ };
721
+ });
722
+ }
723
+ resolveColDefTooltip(userTooltip, params) {
724
+ if (typeof userTooltip === 'function') {
725
+ return userTooltip(params);
726
+ }
727
+ if (typeof userTooltip === 'string') {
728
+ return userTooltip;
729
+ }
730
+ if (userTooltip === true) {
731
+ return params.valueFormatted ?? params.value;
732
+ }
733
+ return undefined;
734
+ }
735
+ getStyledColumnTooltip(styledColumn, abColumn) {
736
+ if (styledColumn.IconStyle && !isUnsupportedColumnDataTypeForIconStyle(abColumn.dataType)) {
737
+ const iconTokens = styledColumn.IconStyle.ToolTipText ?? [];
738
+ if (iconTokens.length === 0) {
738
739
  return undefined;
739
740
  }
740
- hasTooptip = true;
741
741
  return (params) => {
742
- const isRangeBar = tooltipStyle === styledColumn.RangeBarStyle;
743
- let min;
744
- let max;
745
- if (isRangeBar) {
746
- const rangeStyle = styledColumn.RangeBarStyle;
747
- min = this.resolveRangeBarBound(rangeStyle.Min, abColumn, params.node);
748
- max = this.resolveRangeBarBound(rangeStyle.Max, abColumn, params.node);
742
+ const parts = [];
743
+ if (iconTokens.includes('CellValue')) {
744
+ parts.push(String(params.value ?? ''));
749
745
  }
750
- else {
751
- min = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMinValue(styledColumn, abColumn, params.node, params.value);
752
- max = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMaxValue(styledColumn, abColumn, params.node, params.value);
746
+ if (iconTokens.includes('IconDescription')) {
747
+ const matched = findIconStyleMappingForValue(styledColumn.IconStyle, params.value);
748
+ if (matched?.Description) {
749
+ parts.push(matched.Description);
750
+ }
753
751
  }
752
+ const trimmed = parts.filter(Boolean).join(' · ').trim();
753
+ return trimmed ? trimmed : String(params.value ?? '');
754
+ };
755
+ }
756
+ if (styledColumn.RatingStyle) {
757
+ const ratingToolTip = styledColumn.RatingStyle.ToolTipText ?? [];
758
+ if (ratingToolTip.length === 0) {
759
+ return undefined;
760
+ }
761
+ const ratingMax = styledColumn.RatingStyle.Max ?? 5;
762
+ return (params) => {
754
763
  let returnValue = '';
755
- if (textOptions.includes('CellValue')) {
764
+ if (ratingToolTip.includes('CellValue')) {
756
765
  returnValue = String(params.value ?? '');
757
766
  }
758
- if (textOptions.includes('PercentageValue') && min != undefined && max != undefined) {
759
- let percentageValue;
760
- if (styledColumn.PercentBarStyle?.ColumnComparison) {
761
- const absMax = Math.abs(max);
762
- percentageValue = absMax === 0 ? 0 : (Number(params.value) / absMax) * 100;
767
+ if (ratingToolTip.includes('PercentageValue') && ratingMax > 0) {
768
+ const n = Number(params.value);
769
+ if (!isNaN(n)) {
770
+ const clamped = clamp(n, 0, ratingMax);
771
+ const percentageValue = (clamped / ratingMax) * 100;
772
+ const pct = `${percentageValue.toFixed(0)}%`;
773
+ returnValue = returnValue ? `${returnValue} (${pct})` : pct;
763
774
  }
764
- else {
765
- const scaleSpan = max - min;
766
- const clamped = clamp(Number(params.value), min, max);
767
- percentageValue = scaleSpan === 0 ? 0 : ((clamped - min) / scaleSpan) * 100;
768
- }
769
- returnValue += ` (${percentageValue.toFixed(0)}%)`;
770
775
  }
771
776
  const trimmed = returnValue.trim();
772
777
  return trimmed ? trimmed : String(params.value ?? '');
773
778
  };
774
- });
779
+ }
780
+ const tooltipStyle = styledColumn.PercentBarStyle ??
781
+ styledColumn.BulletChartStyle ??
782
+ styledColumn.GradientStyle ??
783
+ styledColumn.RangeBarStyle;
784
+ const textOptions = tooltipStyle?.ToolTipText;
785
+ if (!tooltipStyle || !textOptions || textOptions.length === 0) {
786
+ return undefined;
787
+ }
788
+ return (params) => {
789
+ const isRangeBar = tooltipStyle === styledColumn.RangeBarStyle;
790
+ let min;
791
+ let max;
792
+ if (isRangeBar) {
793
+ const rangeStyle = styledColumn.RangeBarStyle;
794
+ min = this.resolveRangeBarBound(rangeStyle.Min, abColumn, params.node);
795
+ max = this.resolveRangeBarBound(rangeStyle.Max, abColumn, params.node);
796
+ }
797
+ else {
798
+ min = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMinValue(styledColumn, abColumn, params.node, params.value);
799
+ max = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMaxValue(styledColumn, abColumn, params.node, params.value);
800
+ }
801
+ let returnValue = '';
802
+ if (textOptions.includes('CellValue')) {
803
+ returnValue = String(params.value ?? '');
804
+ }
805
+ if (textOptions.includes('PercentageValue') && min != undefined && max != undefined) {
806
+ let percentageValue;
807
+ if (styledColumn.PercentBarStyle?.ColumnComparison) {
808
+ const absMax = Math.abs(max);
809
+ percentageValue = absMax === 0 ? 0 : (Number(params.value) / absMax) * 100;
810
+ }
811
+ else {
812
+ const scaleSpan = max - min;
813
+ const clamped = clamp(Number(params.value), min, max);
814
+ percentageValue = scaleSpan === 0 ? 0 : ((clamped - min) / scaleSpan) * 100;
815
+ }
816
+ returnValue += ` (${percentageValue.toFixed(0)}%)`;
817
+ }
818
+ const trimmed = returnValue.trim();
819
+ return trimmed ? trimmed : String(params.value ?? '');
820
+ };
775
821
  }
776
822
  resolveRangeBarBound(bound, abColumn, rowNode) {
777
823
  if (bound == undefined) {
@@ -1293,7 +1339,7 @@ export class AgGridColumnAdapter {
1293
1339
  if (!note) {
1294
1340
  return;
1295
1341
  }
1296
- const noteType = note.NoteType ?? this.adaptableApi.optionsApi.getNoteOptions()?.defaultNoteType ?? 'Info';
1342
+ const noteType = this.adaptableApi.noteApi.internalApi.getNoteType(note);
1297
1343
  return `ab-NoteType-${noteType}`;
1298
1344
  }
1299
1345
  getCommentCellClassName(gridCell, params) {
@@ -52,6 +52,11 @@ export declare class AgGridExportAdapter {
52
52
  buildExportProcessData(config: ExportConfig): ExportProcessData;
53
53
  private buildExportParams;
54
54
  private buildBaseExportParams;
55
+ /**
56
+ * Excel cannot colour the note indicator per comment, so when any Note has a non-default type,
57
+ * the type is prepended to every exported note text (e.g. `Warning: <text>`).
58
+ */
59
+ private computeProcessNoteCallback;
55
60
  private computeProcessRowGroupCallback;
56
61
  private computeProcessCellCallback;
57
62
  private getReportColsAndRows;
@@ -137,10 +137,18 @@ export class AgGridExportAdapter {
137
137
  if (exportContext.format === 'Excel' || exportContext.format === 'VisualExcel') {
138
138
  const excelExportParams = baseExportParams;
139
139
  excelExportParams.sheetName = resolveValueOrFunction(this.exportOptions.excelSheetName, this.adaptableApi.exportApi.internalApi.buildBaseExportContext(exportContext.report.Name, exportContext.format, exportContext.destination));
140
+ excelExportParams.processNoteCallback = this.computeProcessNoteCallback();
140
141
  return excelExportParams;
141
142
  }
142
143
  const csvExportParams = baseExportParams;
143
144
  csvExportParams.columnSeparator = this.getCsvSeparator(exportContext);
145
+ if (exportContext.format !== 'CSV') {
146
+ Object.keys(this.agGridApi.getGridOption('defaultCsvExportParams') ?? {}).forEach((key) => {
147
+ if (!(key in csvExportParams)) {
148
+ csvExportParams[key] = undefined;
149
+ }
150
+ });
151
+ }
144
152
  return csvExportParams;
145
153
  }
146
154
  buildBaseExportParams(exportContext) {
@@ -161,6 +169,29 @@ export class AgGridExportAdapter {
161
169
  params.processRowGroupCallback = this.computeProcessRowGroupCallback(exportContext);
162
170
  return params;
163
171
  }
172
+ computeProcessNoteCallback() {
173
+ const noteInternalApi = this.adaptableApi.noteApi.internalApi;
174
+ if (!noteInternalApi.isAgGridNotesActive() || !noteInternalApi.hasNonDefaultNoteTypes()) {
175
+ return undefined;
176
+ }
177
+ return (params) => {
178
+ const { excelNote, node, column } = params;
179
+ if (!excelNote || !node || !column) {
180
+ return undefined;
181
+ }
182
+ const note = this.adaptableApi.noteApi.getNoteForCell({
183
+ PrimaryKeyValue: this.adaptableApi.gridApi.getPrimaryKeyValueForRowNode(node),
184
+ ColumnId: column.getColId(),
185
+ });
186
+ if (!note) {
187
+ return undefined;
188
+ }
189
+ return {
190
+ ...excelNote,
191
+ text: `${noteInternalApi.getNoteType(note)}: ${excelNote.text}`,
192
+ };
193
+ };
194
+ }
164
195
  computeProcessRowGroupCallback(exportContext) {
165
196
  return (params) => {
166
197
  let rowGroupNode = params.node;
@@ -182,7 +182,7 @@ export class AgGridMenuAdapter {
182
182
  const agGridMenuItems = this.filterSuppressedAgGridDualUiMenuItems(params.defaultItems ? [...params.defaultItems] : []);
183
183
  const agGridCopyItems = agGridMenuItems.filter((item) => ['copy', 'copyWithHeaders', 'copyWithGroupHeaders', 'cut', 'paste'].includes(item));
184
184
  const otherAgGridItems = agGridMenuItems.filter((item) => !agGridCopyItems.includes(item) &&
185
- !['export', 'csvExport', 'excelExport'].includes(item));
185
+ !['export', 'csvExport', 'excelExport', 'pdfExport'].includes(item));
186
186
  const agGridDefaultStructure = [
187
187
  {
188
188
  menuType: 'Group',
@@ -0,0 +1,9 @@
1
+ import { GridOptions } from 'ag-grid-enterprise';
2
+ /**
3
+ * Copies onto `gridOptions` the options set with AG Grid's `provideGlobalGridOptions` which the grid
4
+ * itself does not set, so AdapTable handles them exactly as if they were set on the grid.
5
+ *
6
+ * Must run before AdapTable reads or wraps any GridOptions property: AdapTable writes its own value
7
+ * for the properties it manages, and AG Grid's global merge never overrides a value set on the grid.
8
+ */
9
+ export declare function applyGlobalGridOptions(gridOptions: GridOptions): GridOptions;
@@ -0,0 +1,36 @@
1
+ import { _getGlobalGridOption, _GET_ALL_GRID_OPTIONS } from 'ag-grid-enterprise';
2
+ export function applyGlobalGridOptions(gridOptions) {
3
+ if (!gridOptions) {
4
+ return gridOptions;
5
+ }
6
+ const options = gridOptions;
7
+ for (const key of _GET_ALL_GRID_OPTIONS()) {
8
+ if (options[key] !== undefined) {
9
+ continue;
10
+ }
11
+ const globalValue = _getGlobalGridOption(key);
12
+ if (globalValue !== undefined) {
13
+ options[key] = copyGlobalValue(globalValue);
14
+ }
15
+ }
16
+ return gridOptions;
17
+ }
18
+ function copyGlobalValue(value) {
19
+ if (Array.isArray(value)) {
20
+ return [...value];
21
+ }
22
+ return copyPlainObjects(value);
23
+ }
24
+ function copyPlainObjects(value) {
25
+ if (!isPlainObject(value)) {
26
+ return value;
27
+ }
28
+ const copy = {};
29
+ for (const [key, nestedValue] of Object.entries(value)) {
30
+ copy[key] = copyPlainObjects(nestedValue);
31
+ }
32
+ return copy;
33
+ }
34
+ function isPlainObject(value) {
35
+ return typeof value === 'object' && value !== null && value.constructor === Object;
36
+ }
@@ -2,6 +2,7 @@ import { Badge } from '../../View/StyledColumn/Badge';
2
2
  import { renderWithAdaptableContext } from '../../View/AdaptableContext';
3
3
  import * as React from 'react';
4
4
  import { shouldRenderStyledColumnOnRow } from '../../Utilities/Helpers/StyledColumns/StyledColumnHelper';
5
+ import { getPerfRecorder } from '../../devTools/PerfStore';
5
6
  const OVERFLOW_CLASS = {
6
7
  Truncate: 'ab-Badge__wrapper--truncate',
7
8
  Wrap: 'ab-Badge__wrapper--wrap',
@@ -25,6 +26,13 @@ export const getBadgeRendererForColumn = (styledColumn, abColumn, api) => {
25
26
  const wrapperClassName = `ab-Badge__wrapper ${OVERFLOW_CLASS[overflowMode]}`;
26
27
  const spacing = typeof badgeStyle.Spacing === 'number' ? badgeStyle.Spacing : null;
27
28
  const rowJustify = resolveBadgeRowJustify(badgeStyle.Font?.Alignment);
29
+ const perfKey = `badge:${abColumn.columnId}`;
30
+ const describePerf = () => ({
31
+ module: 'StyledColumn',
32
+ objectId: styledColumn.Uuid,
33
+ objectName: styledColumn.Name,
34
+ columnId: abColumn.columnId,
35
+ });
28
36
  return class BadgetRenderer {
29
37
  eGui;
30
38
  unmountReactRoot;
@@ -33,6 +41,20 @@ export const getBadgeRendererForColumn = (styledColumn, abColumn, api) => {
33
41
  return adaptable;
34
42
  }
35
43
  init(params) {
44
+ const recorder = getPerfRecorder(this.getAdaptableInstance(params)?.adaptableOptions?.adaptableId);
45
+ if (!recorder) {
46
+ this.initNow(params);
47
+ return;
48
+ }
49
+ const start = performance.now();
50
+ try {
51
+ this.initNow(params);
52
+ }
53
+ finally {
54
+ recorder.add('badge', perfKey, start, describePerf);
55
+ }
56
+ }
57
+ initNow(params) {
36
58
  const adaptable = this.getAdaptableInstance(params);
37
59
  const adaptableApi = adaptable.api;
38
60
  this.eGui = document.createElement('div');
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Cached aggregations of a numeric column's distinct values (Styled Columns use them for
3
+ * percent bars, gradients and ranges such as "Col-Min" / "Col-Max").
4
+ */
5
+ export type ColumnMinMaxCacheEntry = {
6
+ min?: number;
7
+ max?: number;
8
+ avg?: number;
9
+ median?: number;
10
+ };
11
+ /** Lowest and highest value in one pass (no spread: very large columns overflow the stack) */
12
+ export declare function computeMinMax(values: number[]): {
13
+ min: number;
14
+ max: number;
15
+ } | undefined;
16
+ /**
17
+ * The cache entry after one cell changed from `oldValue` to `newValue`, without reading the
18
+ * column again: ticking data would otherwise make the next render scan every row, on every tick.
19
+ *
20
+ * - A new value beyond the min or max becomes the new min or max.
21
+ * - When the old value *was* the min or max, it may have been the only one: that aggregation is
22
+ * dropped and recomputed when next asked.
23
+ * - Average and median depend on every distinct value: always recomputed.
24
+ * - Anything that is not a plain numeric change (or `trigger` other than edit, tick or undo)
25
+ * drops the whole entry.
26
+ *
27
+ * Returns `undefined` when nothing is left to keep.
28
+ */
29
+ export declare function updateColumnMinMaxCacheEntry(entry: ColumnMinMaxCacheEntry | undefined, change: {
30
+ oldValue?: unknown;
31
+ newValue?: unknown;
32
+ trigger?: string;
33
+ }): ColumnMinMaxCacheEntry | undefined;
@@ -0,0 +1,50 @@
1
+ function isNumber(value) {
2
+ return typeof value === 'number' && !isNaN(value);
3
+ }
4
+ export function computeMinMax(values) {
5
+ if (!values.length) {
6
+ return undefined;
7
+ }
8
+ let min = values[0];
9
+ let max = values[0];
10
+ for (let index = 1; index < values.length; index++) {
11
+ const value = values[index];
12
+ if (value < min) {
13
+ min = value;
14
+ }
15
+ else if (value > max) {
16
+ max = value;
17
+ }
18
+ }
19
+ return { min, max };
20
+ }
21
+ export function updateColumnMinMaxCacheEntry(entry, change) {
22
+ if (!entry) {
23
+ return undefined;
24
+ }
25
+ const { oldValue, newValue, trigger } = change;
26
+ const incremental = (trigger === 'edit' || trigger === 'tick' || trigger === 'undo') &&
27
+ isNumber(newValue) &&
28
+ (oldValue == null || isNumber(oldValue));
29
+ if (!incremental) {
30
+ return undefined;
31
+ }
32
+ const next = {};
33
+ if (entry.min !== undefined) {
34
+ if (newValue <= entry.min) {
35
+ next.min = newValue;
36
+ }
37
+ else if (oldValue !== entry.min) {
38
+ next.min = entry.min;
39
+ }
40
+ }
41
+ if (entry.max !== undefined) {
42
+ if (newValue >= entry.max) {
43
+ next.max = newValue;
44
+ }
45
+ else if (oldValue !== entry.max) {
46
+ next.max = entry.max;
47
+ }
48
+ }
49
+ return next.min === undefined && next.max === undefined ? undefined : next;
50
+ }