UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

339 lines (338 loc) 16.4 kB
/// <reference types="react" /> import { AdaptableOptions } from '../AdaptableOptions/AdaptableOptions'; import { ChartRef, Column, GridApi, GridOptions, IRowNode, Module, RowModelType } from 'ag-grid-enterprise'; import { AdaptableLogger } from './AdaptableLogger'; import { AdaptableApi, DestroyConfig } from '../Api/AdaptableApi'; import { AdaptableVariant, IAdaptable, NormalizeAdaptableStateOptions } from '../AdaptableInterfaces/IAdaptable'; import { EmitterCallback } from '../Utilities/Emitter'; import { AdaptablePlugin } from '../AdaptableOptions/AdaptablePlugin'; import { AgGridAdapter } from './AgGridAdapter'; import { IDataService } from '../Utilities/Services/Interface/IDataService'; import { AdaptableState } from '../AdaptableState/AdaptableState'; import { IAdaptableStore } from '../Redux/Store/Interface/IAdaptableStore'; import { ICalculatedColumnExpressionService } from '../Utilities/Services/Interface/ICalculatedColumnExpressionService'; import { IModuleService } from '../Utilities/Services/Interface/IModuleService'; import { IValidationService } from '../Utilities/Services/Interface/IValidationService'; import { IQueryLanguageService } from '../Utilities/Services/Interface/IQueryLanguageService'; import { IAlertService } from '../Utilities/Services/Interface/IAlertService'; import { ITeamSharingService } from '../Utilities/Services/Interface/ITeamSharingService'; import { IMetamodelService } from '../Utilities/Services/Interface/IMetamodelService'; import { Fdc3Service } from '../Utilities/Services/Fdc3Service'; import { AnnotationsService } from '../Utilities/Services/AnnotationsService'; import { IModuleCollection } from '../Strategy/Interface/IModule'; import { AgGridMenuAdapter } from './AgGridMenuAdapter'; import { AdaptableColumn, AdaptableTheme, ChartDefinition, ColumnSort, DataUpdateConfig, GridCell, Layout, SelectedCellInfo, SelectedRowInfo } from '../types'; import { RenderReactRootFn } from '../renderReactRoot'; import { AgGridOptionsService } from './AgGridOptionsService'; import { AgGridColumnAdapter } from './AgGridColumnAdapter'; import { RowFormService } from '../Utilities/Services/RowFormService'; import { GridCellWithCount } from '../AdaptableState/Selection/GridCell'; import { FlashingCellService } from '../Utilities/Services/FlashingCellService'; import { AgGridExportAdapter } from './AgGridExportAdapter'; import { AgGridThemeAdapter } from './AgGridThemeAdapter'; export type AdaptableLifecycleState = 'initial' | 'preprocessOptions' | 'initAdaptableState' | 'setupAgGrid' | 'initAgGrid' | 'agGridReady' | 'available' | 'ready' | 'preDestroyed'; type RenderAgGridFrameworkComponentResult = false | GridApi; interface AdaptableInitInternalConfig<TData = any> { variant: AdaptableVariant; adaptableOptions: AdaptableOptions<TData>; gridOptions: GridOptions<TData>; modules?: Module[]; isDetailGrid?: boolean; isDetailGridForRowIndex?: number; /** * Adaptable init hook for rendering the React/Angular AG Grid component */ renderAgGridFrameworkComponent?: (gridOptions: GridOptions<TData>) => Promise<RenderAgGridFrameworkComponentResult>; /** * We need this to pass a reference to the internal AG Grid module from where we extract the beans. * This has to be done here and not in the core module because in some instances (e.g. Angular) different class instances are provided in core and wrapper * */ getAgGridColumnApiModuleReference?: () => Module; } export declare class AdaptableAgGrid implements IAdaptable { logger: AdaptableLogger; private _id; lifecycleState: AdaptableLifecycleState; variant: AdaptableVariant; private emitter; /** * Runtime flags */ hasAutogeneratedPrimaryKey: boolean; hasAdaptableToolPanel: boolean; private initWithLazyData; _rawAdaptableOptions: AdaptableOptions; adaptableOptions: AdaptableOptions; _isDetailGrid: boolean; _isDetailGridForIndex?: number; agGridOptionsService: AgGridOptionsService; agGridAdapter: AgGridAdapter; agGridColumnAdapter: AgGridColumnAdapter; agGridMenuAdapter: AgGridMenuAdapter; agGridExportAdapter: AgGridExportAdapter; agGridThemeAdapter: AgGridThemeAdapter; private DANGER_USE_GETTER_adaptableContainerElement; private DANGER_USE_GETTER_agGridContainerElement; api: AdaptableApi; adaptableStore: IAdaptableStore; adaptableModules: IModuleCollection; DataService: IDataService; CalculatedColumnExpressionService: ICalculatedColumnExpressionService; ModuleService: IModuleService; ValidationService: IValidationService; QueryLanguageService: IQueryLanguageService; AlertService: IAlertService; TeamSharingService: ITeamSharingService; MetamodelService: IMetamodelService; RowFormService: RowFormService; Fdc3Service: Fdc3Service; AnnotationsService: AnnotationsService; FlashingCellService: FlashingCellService; private LicenseService; private ChartingService; private ThemeService; private rowListeners; private throttleFilterOnDataChange; private debouncedSetSelectedRows; private debouncedSetSelectedCells; private agGridListenerKeydown; private agGridListenerMouseEnter; private agGridListenerMouseLeave; private listenerGlobalColumnEventsThatTriggerStateChange; private listenerGlobalColumnEventsThatTriggerAutoLayoutSave; private listenerGlobalRowGroupEventsThatTriggerAutoLayoutSave; private listenerGlobalSetRowSelection; private listenerCellEditingStarted; private listenerFirstDataRendered; private listenerPivotChanged; private listenerColumnRowGroupChanged; private listenerColumnResized; private listenerCellSelectionChanged; private listenerSortChanged; private listenerModelUpdated; private filteredOutPrimaryKeys; private layoutManager; private columnMinMaxValuesCache; renderReactRoot: RenderReactRootFn; private unmountReactRoot?; private unmountLoadingScreen?; /** * Temporary, these are MIGRATION technical debts, and should be removed as soon as possible */ private adaptableStatusPanelKeys; _PRIVATE_adaptableJSXElement: React.JSX.Element; private _prevLayout; private __prevLayoutForOnChange; constructor(config?: { getAgGridColumnApiModuleReference?: () => Module; }); static forEachAdaptable(fn: (adaptable: AdaptableAgGrid) => void): void; private static collectInstance; private static dismissInstance; get isAgGridInitialising(): boolean; get isReady(): boolean; get isAvailable(): boolean; get isDestroyed(): boolean; _emit: (eventName: string, data?: any) => Promise<any>; _emitSync: (eventName: string, data?: any) => any; _on: (eventName: string, callback: EmitterCallback) => (() => void); _onIncludeFired: (eventName: string, callback: EmitterCallback) => (() => void); /** * Internal initializer for Adaptable, directly called by the React and Angular Adaptable wrappers * @private */ static _initInternal(config: AdaptableInitInternalConfig): Promise<AdaptableApi>; private _initAdaptableAgGrid; midwayDestroy(): void; normalizeAdaptableState(state: AdaptableState, agGridOptions: NormalizeAdaptableStateOptions): AdaptableState; private normaliseLayoutState; private normaliseToolPanelState; applyFiltering(): void; showQuickFilter(): void; hideQuickFilter(): void; private normalizeAdaptableOptions; private setInitialGridOptions; /** * Either initializes the AG Grid instance or delegates it to the framework wrappers (React/Anglar) */ private initializeAgGrid; useRowNodeLookUp(): boolean; getAgGridRegisteredModules(): Module[]; getAgGridContainerElement(): HTMLElement | null; getAdaptableContainerElement(): HTMLElement; refreshSelectedCellsState(): SelectedCellInfo | undefined; refreshSelectedRowsState(): SelectedRowInfo | undefined; isGridRowSelectable(): boolean; isGridRangeSelectable(): boolean; private initAdaptableStore; private mapAdaptableStateToAgGridState; private addGridEventListeners; private shouldAutoSizeLayout; private autoSizeLayoutIfNeeded; forPlugins(callback: (plugin: AdaptablePlugin) => any): void; getPluginProperty(pluginId: string, propertyName: string, ...args: any): any; getPlugin(pluginId: string): AdaptablePlugin; private initServices; private initLicenseService; private initModules; /** * This method contains all the updates on the AdaptableState which were made AFTER Adaptbale was ready * This was contidioned because we required AG Grid to be ready before we could make these updates * We should be able to refactor the code, no that we no fore sure that Adaptable State is ready BEFORE AG Grid init */ private temporaryAdaptableStateUpdates; private validatePrimaryKey; private deriveAdaptableColumnStateFromAgGrid; private checkShouldClearExistingFiltersOrSearches; getGridCellFromRowNode(rowNode: IRowNode, columnId: string): GridCell | undefined; /** * Use (lazy evaluated) getters to avoid unnecessary calculations and memoization to avoid recalculating the same values */ private createGridCell; getPrimaryKeyValueFromRowNode(rowNode: IRowNode, gridApi?: GridApi): string | number; getRawValueFromRowNode(rowNode: IRowNode, columnId: string): any; getDisplayValueFromRowNode(rowNode: IRowNode, columnId: string): string | undefined; getDisplayValueFromRawValue(rowNode: IRowNode, columnId: string, rawValue: any): string | undefined; private getCleanValue; getNormalisedValueFromRawValue(rawValue: any, column: AdaptableColumn): string | number | boolean | Date | unknown; updateColumnModelAndRefreshGrid(): void; redrawBody(): void; refreshHeader(): void; redrawRows(rowNodes?: IRowNode[]): void; redrawRow(rowNode: IRowNode): void; refreshCell(rowNode: IRowNode, column: string | any, forceUpdate: boolean, suppressFlash?: boolean): void; refreshCells(rowNode: IRowNode, columns: (string | Column)[], forceUpdate: boolean, suppressFlash?: boolean): void; refreshAllCells(forceUpdate?: boolean): void; refreshColumns(columns: (string | Column)[], forceUpdate: boolean, suppressFlash?: boolean): void; jumpToRow(rowNode: IRowNode): void; jumpToColumn(columnId: string): void; jumpToCell(columnId: string, rowNode: IRowNode): void; selectColumn(columnId: string, config?: { keepExistingSelection?: boolean; }): void; selectColumns(columnIds: string[], config?: { keepExistingSelection?: boolean; }): void; selectAll(): void; deselectAll(): void; setGridData(dataSource: any[]): void; getGridData(): any[]; private addSyntheticPrimaryKey; private addSyntheticPrimaryKeyIfMissing; getFirstDisplayedRowNode(): IRowNode; getFirstRowNode(): IRowNode | undefined; updateRowGroupsExpandedState(layout?: Layout): void; isGroupRowNode(rowNode: IRowNode): boolean; getFilteredData(): any[]; updateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>; addRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>; addOrUpdateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<{ added: IRowNode[]; updated: IRowNode[]; }>; deleteRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>; getRowNodeForPrimaryKey(primaryKeyValue: any): any; hideColumn(columnId: string): void; showColumn(columnId: string): void; autoSizeColumn(columnId: string): void; autoSizeColumns(columnIds?: string[]): void; autoSizeAllColumns(): void; getDistinctValuesForColumn(column: AdaptableColumn): Promise<GridCell[]>; getDistinctFilterValuesForColumn(options: { column: AdaptableColumn; currentSearchValue: string; }): Promise<GridCell[]>; getDistinctEditValuesForColumn(options: { column: AdaptableColumn; currentSearchValue: string; gridCell?: GridCell; }): Promise<GridCell[]>; getDistinctGridCellsForColumn(column: AdaptableColumn): GridCellWithCount[]; private getGridCellsForCustomColumnValues; private isPrimaryKeyVisible; private addDistinctColumnValue; private getUniqueGridCells; getGridCellsForColumn(columnId: string, onlyVisibleRows?: boolean): GridCell[] | undefined; getRowNodesForPrimaryKeys(primaryKeyValues: any[]): any[]; getRowNodeByIndex(index: number): IRowNode; getAgGridStatusPanels(): import("ag-grid-enterprise").StatusPanelDef[]; setDataValue(value: any, column: AdaptableColumn, primaryKeyValue: any, rowNode?: IRowNode): void; forAllRowNodesDo(func: (rowNode: IRowNode, rowIndex: number) => void, config?: { includeGroupRows?: boolean; filterFn?: (rowNode: IRowNode) => boolean; }): void; forAllVisibleRowNodesDo(func: (rowNode: IRowNode, rowIndex: number) => void, config?: { includeGroupRows?: boolean; filterFn?: (rowNode: IRowNode) => boolean; }): void; getAgGridRowModelType(gridOptions?: GridOptions): RowModelType; getAllRowNodes(config?: { includeGroupRows?: boolean; filterFn?: (rowNode: IRowNode) => boolean; }): IRowNode[]; getGroupRowNodes(): IRowNode[]; getRowsInViewport(): IRowNode[]; isRowNodeVisible(rowNode: IRowNode): boolean; selectNodes(rowNodes: IRowNode[], clearSelection: boolean): void; deSelectNodes(rowNodes: IRowNode[], clearSelection: boolean): void; selectNode(rowNode: IRowNode, clearSelection: boolean): void; deSelectNode(rowNode: IRowNode, clearSelection: boolean): void; selectCells(columnIds: string[], startNode: IRowNode, endNode: IRowNode, clearSelection?: boolean): void; getAgGridColumnType(columnId: string): string | string[]; setColumnSort(columnSorts: ColumnSort[]): void; clearColumnSort(): void; clearColumnFiltering(): void; clearColumnFilteringForColumns(columnIds: string[]): void; canGenerateCharts(): boolean; canDisplaySparklines(): boolean; showCharts(chartsDefinitions: ChartDefinition[], chartContainer?: HTMLElement): ChartRef[]; showChart(chartDefinition: ChartDefinition, container?: HTMLElement): ChartRef; updateChart(chart: ChartDefinition): void; getChartModels(): import("ag-grid-enterprise").ChartModel[]; getRowCount(): number; getVisibleRowCount(): number; getColumnCount(): number; getVisibleColumnCount(): number; isGridGroupingActive(): boolean; setAgGridQuickSearch(searchText: string): void; clearAgGridQuickSearch(): void; applyAdaptableTheme(theme: AdaptableTheme | string): void; setRowGroupColumns(columnIds: string[]): void; getAllGridColumns(): Column<any>[]; clearRowGroupColumns(): void; expandAllRowGroups(): void; collapseAllRowGroups(): void; expandRowGroupsForValues(columnValues: any[]): void; getAgGridColumnForColumnId(columnId: string): Column; getMinMaxCachedValueForColumn(column: AdaptableColumn, minMax: 'min' | 'max'): number; destroy(config?: DestroyConfig): void; canExportToExcel(): boolean; canExportToCsv(): boolean; isQuickFilterAvailable(): boolean; private hasFloatingFilterOnAtLeastOneColumn; getChartRef(chartId: string): ChartRef; setLayout(layout?: Layout): void; private getActiveAdaptableAggFuncForCol; private onRowDataChanged; private onCellDataChanged; private isUndoChange; /** * There are a few things we need to do AFTER we edit a cell and it makes sense to put them in one place */ private performPostEditChecks; private refreshCellsBasedOnCellDataChange; private refreshColumnsBasedOnCellDataChange; private checkStyledColumnComparisonChanges; private checkFormatColumnPredicateStyleChanges; private checkFreeTextColumnChanges; private checkFormatColumnExpressionStyleChanges; private checkIfChangedCellCurrentlySelected; private resetMinMaxCachedValueForColumn; private filterOnDataChange; refreshLayout(): void; private isRowGroupDifferentInLayout; private onLayoutChange; private validateColumnDefTypes; } export {};