@adaptabletools/adaptable-cjs 18.0.10-canary.3 → 18.0.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "18.0.10-canary.3",
3
+ "version": "18.0.11",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1,4 +1,5 @@
1
1
  import { AdaptableColumn, AdaptableColumnDataType } from '../../types';
2
+ import { ColDef, ColGroupDef, ColumnPinnedType, IAggFunc } from '@ag-grid-community/core';
2
3
  /**
3
4
  * Provides run-time access to AdapTable Column related features
4
5
  */
@@ -275,4 +276,47 @@ export interface ColumnApi {
275
276
  * Returns all columns currently Row Grouped
276
277
  */
277
278
  getRowGroupedColumns(): AdaptableColumn[];
279
+ /**
280
+ * Updates the Column Configuration for a given Column. It will update the current Layout with the new configuration.
281
+ * @param columnConfiguration - the Column Configuration to set
282
+ */
283
+ updateColumnConfiguration(columnConfiguration: ColumnConfig): void;
284
+ /**
285
+ * Updates the Column Configurations for a list of Columns. It will update the current Layout with the new configurations.
286
+ * @param columnConfigurations - the Column Configurations to set
287
+ */
288
+ updateColumnConfigurations(columnConfigurations: ColumnConfig[]): void;
289
+ /**
290
+ * Sets the Column Definitions for the Grid
291
+ */
292
+ setColumnDefinitions(columnDefinitions: (ColDef | ColGroupDef)[]): void;
293
+ }
294
+ /**
295
+ * Column Configuration
296
+ */
297
+ export interface ColumnConfig {
298
+ /** Column Id */
299
+ colId: string;
300
+ /** True if the column is hidden */
301
+ hide?: boolean | null;
302
+ /** Width of the column in pixels */
303
+ width?: number;
304
+ /** Column's flex if flex is set */
305
+ flex?: number | null;
306
+ /** Sort applied to the column */
307
+ sort?: 'asc' | 'desc' | null;
308
+ /** The order of the sort, if sorting by many columns */
309
+ sortIndex?: number | null;
310
+ /** The aggregation function applied */
311
+ aggFunc?: string | IAggFunc | null;
312
+ /** True if pivot active */
313
+ pivot?: boolean | null;
314
+ /** The order of the pivot, if pivoting by many columns */
315
+ pivotIndex?: number | null;
316
+ /** Set if column is pinned */
317
+ pinned?: ColumnPinnedType;
318
+ /** True if row group active */
319
+ rowGroup?: boolean | null;
320
+ /** The order of the row group, if grouping by many columns */
321
+ rowGroupIndex?: number | null;
278
322
  }
@@ -1,8 +1,9 @@
1
1
  import { ApiBase } from './ApiBase';
2
2
  import { AdaptableColumn, AdaptableColumnDataType } from '../../PredefinedConfig/Common/AdaptableColumn';
3
- import { ColumnApi } from '../ColumnApi';
3
+ import { ColumnApi, ColumnConfig } from '../ColumnApi';
4
4
  import { IAdaptable } from '../../AdaptableInterfaces/IAdaptable';
5
5
  import { ColumnInternalApi } from '../Internal/ColumnInternalApi';
6
+ import { ColDef, ColGroupDef } from '@ag-grid-community/core';
6
7
  export declare function isAutoRowGroupColumn(columnId: string): boolean;
7
8
  export declare function isAutoPivotColumn(columnId: string): boolean;
8
9
  export declare class ColumnApiImpl extends ApiBase implements ColumnApi {
@@ -68,4 +69,7 @@ export declare class ColumnApiImpl extends ApiBase implements ColumnApi {
68
69
  getColumnTypes(): string[];
69
70
  getColumnsByColumnType(columnType: string): AdaptableColumn[];
70
71
  getRowGroupedColumns(): AdaptableColumn[];
72
+ updateColumnConfiguration(columnConfig: ColumnConfig): void;
73
+ updateColumnConfigurations(columnConfigs: ColumnConfig[]): void;
74
+ setColumnDefinitions(columnDefinitions: (ColDef | ColGroupDef)[]): void;
71
75
  }
@@ -5,9 +5,9 @@ const tslib_1 = require("tslib");
5
5
  const ApiBase_1 = require("./ApiBase");
6
6
  const GeneralConstants = tslib_1.__importStar(require("../../Utilities/Constants/GeneralConstants"));
7
7
  const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
8
- const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
9
8
  const ColumnInternalApi_1 = require("../Internal/ColumnInternalApi");
10
9
  const ObjectFactory_1 = require("../../Utilities/ObjectFactory");
10
+ const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
11
11
  function isAutoRowGroupColumn(columnId) {
12
12
  // put this here as there might be other indicators we are not aware of
13
13
  // perhaps with non auto groups ?
@@ -369,5 +369,35 @@ class ColumnApiImpl extends ApiBase_1.ApiBase {
369
369
  return this.getColumnWithColumnId(n);
370
370
  });
371
371
  }
372
+ updateColumnConfiguration(columnConfig) {
373
+ const columnExists = this.doesColumnExist(columnConfig.colId);
374
+ if (!columnExists) {
375
+ this.logWarn(`Column with id ${columnConfig.colId} does not exist, could NOT update configuration`);
376
+ return;
377
+ }
378
+ const columnState = columnConfig;
379
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
380
+ agGridApi.applyColumnState({
381
+ state: [columnState],
382
+ });
383
+ }
384
+ updateColumnConfigurations(columnConfigs) {
385
+ const existingColumnConfigs = columnConfigs.filter((cc) => this.doesColumnExist(cc.colId));
386
+ const notExistingColumnIds = columnConfigs
387
+ .filter((cc) => !this.doesColumnExist(cc.colId))
388
+ .map((cc) => cc.colId);
389
+ notExistingColumnIds.forEach((colId) => {
390
+ this.logWarn(`Column with id ${colId} does not exist, could NOT update configuration`);
391
+ });
392
+ const columnStates = existingColumnConfigs;
393
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
394
+ agGridApi.applyColumnState({
395
+ state: columnStates,
396
+ });
397
+ }
398
+ setColumnDefinitions(columnDefinitions) {
399
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
400
+ agGridApi.setGridOption('columnDefs', columnDefinitions);
401
+ }
372
402
  }
373
403
  exports.ColumnApiImpl = ColumnApiImpl;
@@ -156,7 +156,7 @@ export declare class AdaptableAgGrid implements IAdaptable {
156
156
  * Either initializes the AG Grid instance or delegates it to the framework wrappers (React/Anglar)
157
157
  */
158
158
  private initializeAgGrid;
159
- private getAllColumnDefinitions;
159
+ private getColumnDefinitionsInclSpecialColumns;
160
160
  private getSpecialColDefs;
161
161
  private enhanceColDefsWithSpecialColumns;
162
162
  useRowNodeLookUp(): boolean;
@@ -348,5 +348,6 @@ export declare class AdaptableAgGrid implements IAdaptable {
348
348
  private restoreUnGroupColumnOrder;
349
349
  private onSortChanged;
350
350
  private getColumnSorts;
351
+ private monkeyPatchingGridOptionsUpdates;
351
352
  }
352
353
  export {};
@@ -103,6 +103,7 @@ const AdaptableHelper_1 = require("../Utilities/Helpers/AdaptableHelper");
103
103
  const buildSortedColumnStateForLayout_1 = require("./buildSortedColumnStateForLayout");
104
104
  const RowNodeProto = core_1.RowNode.prototype;
105
105
  const RowNode_dispatchLocalEvent = RowNodeProto.dispatchLocalEvent;
106
+ const GridOptionsService_updateGridOptions = core_1.GridOptionsService.prototype.updateGridOptions;
106
107
  /**
107
108
  * AgGrid does not expose 'cellChanged' and 'dataChanged'
108
109
  * so we have to override `dispatchLocalEvent`
@@ -343,7 +344,7 @@ class AdaptableAgGrid {
343
344
  this.lifecycleState = 'setupAgGrid';
344
345
  const gridOptions = config.gridOptions;
345
346
  // Needed here because special column defs are required for deriving the adaptable column state
346
- const columnDefs = this.getAllColumnDefinitions(gridOptions.columnDefs || []);
347
+ const columnDefs = this.getColumnDefinitionsInclSpecialColumns(gridOptions.columnDefs || []);
347
348
  gridOptions.columnDefs = columnDefs;
348
349
  this.setInitialGridOptions(gridOptions, config.variant);
349
350
  gridOptions.initialState = this.mapAdaptableStateToAgGridState(this.adaptableStore.TheStore.getState(), gridOptions.columnDefs);
@@ -351,12 +352,14 @@ class AdaptableAgGrid {
351
352
  this.agGridAdapter.initialGridOptions = gridOptions;
352
353
  const perfInitAgGrid = this.logger.beginPerf(`initAgGrid()`);
353
354
  const agGridApi = await this.initializeAgGrid(gridOptions, config.modules, config.renderAgGridFrameworkComponent);
354
- (_b = this.unmountLoadingScreen) === null || _b === void 0 ? void 0 : _b.call(this);
355
- perfInitAgGrid.end();
356
355
  if (agGridApi === false) {
357
356
  this.logger.consoleError(`Adaptable failed to initialize AG Grid!`);
358
357
  return Promise.reject('Adaptable failed to initialize AG Grid!');
359
358
  }
359
+ (_b = this.unmountLoadingScreen) === null || _b === void 0 ? void 0 : _b.call(this);
360
+ perfInitAgGrid.end();
361
+ // we need to intercept several AG Grid Api methods and trigger Adaptale state changes
362
+ this.monkeyPatchingGridOptionsUpdates(agGridApi);
360
363
  this.agGridAdapter.setAgGridApi(agGridApi);
361
364
  this.logger.info(`Registered AG Grid modules: `, this.agGridAdapter.getRegisteredModuleNames().sort());
362
365
  /**
@@ -509,8 +512,8 @@ class AdaptableAgGrid {
509
512
  // this.checkShouldClearExistingFiltersOrSearches();
510
513
  // this.applyColumnFiltering();
511
514
  // }
512
- refreshColDefs() {
513
- const freshColDefs = this.getAllColumnDefinitions();
515
+ refreshColDefs(agGridColDefs) {
516
+ const freshColDefs = this.getColumnDefinitionsInclSpecialColumns(agGridColDefs);
514
517
  this.agGridAdapter.setGridOption('columnDefs', freshColDefs);
515
518
  }
516
519
  showQuickFilter() {
@@ -1041,7 +1044,7 @@ class AdaptableAgGrid {
1041
1044
  const agGridApi = (0, core_1.createGrid)(agGridContainer, gridOptions, gridParams);
1042
1045
  return agGridApi;
1043
1046
  }
1044
- getAllColumnDefinitions(agGridColDefs) {
1047
+ getColumnDefinitionsInclSpecialColumns(agGridColDefs) {
1045
1048
  const allColDefs = this.enhanceColDefsWithSpecialColumns(agGridColDefs !== null && agGridColDefs !== void 0 ? agGridColDefs : this.agGridAdapter.getAgGridApi().getColumnDefs());
1046
1049
  return allColDefs;
1047
1050
  }
@@ -1790,7 +1793,12 @@ class AdaptableAgGrid {
1790
1793
  const agGridApi = gridApi || this.agGridAdapter.getAgGridApi();
1791
1794
  let result;
1792
1795
  if (!this.hasAutogeneratedPrimaryKey) {
1793
- result = agGridApi.getCellValue({ colKey: this.adaptableOptions.primaryKey, rowNode });
1796
+ // support both AG Grid pre & post v31.3.x
1797
+ // TODO remove this with the next major Adaptable version
1798
+ result =
1799
+ typeof agGridApi.getCellValue === 'function'
1800
+ ? agGridApi.getCellValue({ colKey: this.adaptableOptions.primaryKey, rowNode })
1801
+ : agGridApi.getValue(this.adaptableOptions.primaryKey, rowNode);
1794
1802
  }
1795
1803
  if (result == undefined && rowNode.data) {
1796
1804
  result = rowNode.data[this.adaptableOptions.primaryKey];
@@ -3935,5 +3943,21 @@ class AdaptableAgGrid {
3935
3943
  };
3936
3944
  });
3937
3945
  }
3946
+ // we need to intercept some of the GridOptions updates and refresh the Adaptable state
3947
+ monkeyPatchingGridOptionsUpdates(agGridApi) {
3948
+ // @ts-ignore
3949
+ const gridOptionsService = agGridApi.gos;
3950
+ const self = this;
3951
+ gridOptionsService.updateGridOptions = function ({ options, force, source = 'api', }) {
3952
+ const passedColumnDefs = options.columnDefs;
3953
+ if (passedColumnDefs) {
3954
+ const colDefsWithSpecialColumns = self.getColumnDefinitionsInclSpecialColumns(passedColumnDefs);
3955
+ options['columnDefs'] = colDefsWithSpecialColumns;
3956
+ self.logger.info(`Added SpecialColumns on GridOptions.columnDefs update (source=${source})`);
3957
+ }
3958
+ // we mutated the options array, so it's OK to use the 'arguments' object
3959
+ GridOptionsService_updateGridOptions.apply(this, arguments);
3960
+ };
3961
+ }
3938
3962
  }
3939
3963
  exports.AdaptableAgGrid = AdaptableAgGrid;
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1715934631988 || Date.now(),
6
- VERSION: "18.0.10-canary.3" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1716176936426 || Date.now(),
6
+ VERSION: "18.0.11" || '--current-version--',
7
7
  };