@adaptabletools/adaptable 18.0.10-canary.3 → 18.0.10

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",
3
- "version": "18.0.10-canary.3",
3
+ "version": "18.0.10",
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
  }
@@ -1,9 +1,9 @@
1
1
  import { ApiBase } from './ApiBase';
2
2
  import * as GeneralConstants from '../../Utilities/Constants/GeneralConstants';
3
3
  import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants';
4
- import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
5
4
  import { ColumnInternalApi } from '../Internal/ColumnInternalApi';
6
5
  import { createBaseContext } from '../../Utilities/ObjectFactory';
6
+ import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
7
7
  export function isAutoRowGroupColumn(columnId) {
8
8
  // put this here as there might be other indicators we are not aware of
9
9
  // perhaps with non auto groups ?
@@ -363,4 +363,34 @@ export class ColumnApiImpl extends ApiBase {
363
363
  return this.getColumnWithColumnId(n);
364
364
  });
365
365
  }
366
+ updateColumnConfiguration(columnConfig) {
367
+ const columnExists = this.doesColumnExist(columnConfig.colId);
368
+ if (!columnExists) {
369
+ this.logWarn(`Column with id ${columnConfig.colId} does not exist, could NOT update configuration`);
370
+ return;
371
+ }
372
+ const columnState = columnConfig;
373
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
374
+ agGridApi.applyColumnState({
375
+ state: [columnState],
376
+ });
377
+ }
378
+ updateColumnConfigurations(columnConfigs) {
379
+ const existingColumnConfigs = columnConfigs.filter((cc) => this.doesColumnExist(cc.colId));
380
+ const notExistingColumnIds = columnConfigs
381
+ .filter((cc) => !this.doesColumnExist(cc.colId))
382
+ .map((cc) => cc.colId);
383
+ notExistingColumnIds.forEach((colId) => {
384
+ this.logWarn(`Column with id ${colId} does not exist, could NOT update configuration`);
385
+ });
386
+ const columnStates = existingColumnConfigs;
387
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
388
+ agGridApi.applyColumnState({
389
+ state: columnStates,
390
+ });
391
+ }
392
+ setColumnDefinitions(columnDefinitions) {
393
+ const agGridApi = this.adaptable.agGridAdapter.getAgGridApi();
394
+ agGridApi.setGridOption('columnDefs', columnDefinitions);
395
+ }
366
396
  }
@@ -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 {};
@@ -1,6 +1,6 @@
1
1
  import throttle from 'lodash/throttle';
2
2
  import debounce from 'lodash/debounce';
3
- import { createGrid, Events, ModuleNames, RowNode, } from '@ag-grid-community/core';
3
+ import { createGrid, Events, ModuleNames, RowNode, GridOptionsService, } from '@ag-grid-community/core';
4
4
  import { AdaptableLogger } from './AdaptableLogger';
5
5
  import { PrimaryKeyDocsLink } from '../Utilities/Constants/DocumentationLinkConstants';
6
6
  import StringExtensions from '../Utilities/Extensions/StringExtensions';
@@ -99,6 +99,7 @@ import { removeUuidAndSource } from '../Utilities/Helpers/AdaptableHelper';
99
99
  import { buildSortedColumnStateForLayout } from './buildSortedColumnStateForLayout';
100
100
  const RowNodeProto = RowNode.prototype;
101
101
  const RowNode_dispatchLocalEvent = RowNodeProto.dispatchLocalEvent;
102
+ const GridOptionsService_updateGridOptions = GridOptionsService.prototype.updateGridOptions;
102
103
  /**
103
104
  * AgGrid does not expose 'cellChanged' and 'dataChanged'
104
105
  * so we have to override `dispatchLocalEvent`
@@ -339,7 +340,7 @@ export class AdaptableAgGrid {
339
340
  this.lifecycleState = 'setupAgGrid';
340
341
  const gridOptions = config.gridOptions;
341
342
  // Needed here because special column defs are required for deriving the adaptable column state
342
- const columnDefs = this.getAllColumnDefinitions(gridOptions.columnDefs || []);
343
+ const columnDefs = this.getColumnDefinitionsInclSpecialColumns(gridOptions.columnDefs || []);
343
344
  gridOptions.columnDefs = columnDefs;
344
345
  this.setInitialGridOptions(gridOptions, config.variant);
345
346
  gridOptions.initialState = this.mapAdaptableStateToAgGridState(this.adaptableStore.TheStore.getState(), gridOptions.columnDefs);
@@ -347,12 +348,14 @@ export class AdaptableAgGrid {
347
348
  this.agGridAdapter.initialGridOptions = gridOptions;
348
349
  const perfInitAgGrid = this.logger.beginPerf(`initAgGrid()`);
349
350
  const agGridApi = await this.initializeAgGrid(gridOptions, config.modules, config.renderAgGridFrameworkComponent);
350
- (_b = this.unmountLoadingScreen) === null || _b === void 0 ? void 0 : _b.call(this);
351
- perfInitAgGrid.end();
352
351
  if (agGridApi === false) {
353
352
  this.logger.consoleError(`Adaptable failed to initialize AG Grid!`);
354
353
  return Promise.reject('Adaptable failed to initialize AG Grid!');
355
354
  }
355
+ (_b = this.unmountLoadingScreen) === null || _b === void 0 ? void 0 : _b.call(this);
356
+ perfInitAgGrid.end();
357
+ // we need to intercept several AG Grid Api methods and trigger Adaptale state changes
358
+ this.monkeyPatchingGridOptionsUpdates(agGridApi);
356
359
  this.agGridAdapter.setAgGridApi(agGridApi);
357
360
  this.logger.info(`Registered AG Grid modules: `, this.agGridAdapter.getRegisteredModuleNames().sort());
358
361
  /**
@@ -505,8 +508,8 @@ export class AdaptableAgGrid {
505
508
  // this.checkShouldClearExistingFiltersOrSearches();
506
509
  // this.applyColumnFiltering();
507
510
  // }
508
- refreshColDefs() {
509
- const freshColDefs = this.getAllColumnDefinitions();
511
+ refreshColDefs(agGridColDefs) {
512
+ const freshColDefs = this.getColumnDefinitionsInclSpecialColumns(agGridColDefs);
510
513
  this.agGridAdapter.setGridOption('columnDefs', freshColDefs);
511
514
  }
512
515
  showQuickFilter() {
@@ -1037,7 +1040,7 @@ export class AdaptableAgGrid {
1037
1040
  const agGridApi = createGrid(agGridContainer, gridOptions, gridParams);
1038
1041
  return agGridApi;
1039
1042
  }
1040
- getAllColumnDefinitions(agGridColDefs) {
1043
+ getColumnDefinitionsInclSpecialColumns(agGridColDefs) {
1041
1044
  const allColDefs = this.enhanceColDefsWithSpecialColumns(agGridColDefs !== null && agGridColDefs !== void 0 ? agGridColDefs : this.agGridAdapter.getAgGridApi().getColumnDefs());
1042
1045
  return allColDefs;
1043
1046
  }
@@ -3931,4 +3934,20 @@ export class AdaptableAgGrid {
3931
3934
  };
3932
3935
  });
3933
3936
  }
3937
+ // we need to intercept some of the GridOptions updates and refresh the Adaptable state
3938
+ monkeyPatchingGridOptionsUpdates(agGridApi) {
3939
+ // @ts-ignore
3940
+ const gridOptionsService = agGridApi.gos;
3941
+ const self = this;
3942
+ gridOptionsService.updateGridOptions = function ({ options, force, source = 'api', }) {
3943
+ const passedColumnDefs = options.columnDefs;
3944
+ if (passedColumnDefs) {
3945
+ const colDefsWithSpecialColumns = self.getColumnDefinitionsInclSpecialColumns(passedColumnDefs);
3946
+ options['columnDefs'] = colDefsWithSpecialColumns;
3947
+ self.logger.info(`Added SpecialColumns on GridOptions.columnDefs update (source=${source})`);
3948
+ }
3949
+ // we mutated the options array, so it's OK to use the 'arguments' object
3950
+ GridOptionsService_updateGridOptions.apply(this, arguments);
3951
+ };
3952
+ }
3934
3953
  }
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  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" || '',
3
- PUBLISH_TIMESTAMP: 1715934602622 || Date.now(),
4
- VERSION: "18.0.10-canary.3" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1715954480588 || Date.now(),
4
+ VERSION: "18.0.10" || '--current-version--',
5
5
  };