UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

79 lines 3.56 kB
import { InjectionToken } from '@angular/core'; import { Observable } from 'rxjs'; import { GridConfig } from './data-grid.model'; /** * Injection token used to provide a configuration strategy service for data-grid component. */ export declare const DATA_GRID_CONFIGURATION_STRATEGY: InjectionToken<DataGridConfigurationStrategy>; /** * Injection token used to provide a context information needed by any * configuration strategy service to retrieve/store configuration data. * Use this token if your context data is static. */ export declare const DATA_GRID_CONFIGURATION_CONTEXT: InjectionToken<GridConfigContext>; /** * Injection token used to provide a context information provider needed by * any configuration strategy service to retrieve/store configuration data. * Use this token is your context data is dynamic. */ export declare const DATA_GRID_CONFIGURATION_CONTEXT_PROVIDER: InjectionToken<GridConfigContextProvider>; /** * Interface for strategy services implementing storage of data-grid configuration data. */ export interface DataGridConfigurationStrategy { /** * A method to retrive configuration data. * @param context Any data needed for the configuration data to be uniquely identified and retrieved. */ getConfig$(context?: GridConfigContext): Observable<GridConfig>; /** * A method to persist configuration data. * @param config Configuration data to persist. * @param context Any data needed for the configuration data to be uniquely identified and retrieved. */ saveConfig$(config: GridConfig, context?: GridConfigContext): Observable<GridConfig>; /** * Allows to retrieve the context provided for the given configuration strategy. */ getContext(): GridConfigContext; /** * Tells if strategy has been already provided with context or context provider. */ isContextKnown(): boolean; } /** * Used to provide context data needed for retrieval/storing of grid configuration data. */ export interface GridConfigContext { [key: string]: any; /** * Provides a way to exclude given parts of the data grid configuration from being persisted. * This allows to e.g. provide a grid where column configuration (order, visibility, soritng, custom columns) * will be persisted, but filters on columns will be reset next time the grid is used. */ configFilter?: GridConfigFilter; } /** * Defines the various types of configuration options for data grid component. */ export type GridConfigPart = 'filter' | 'sort' | 'customColumns' | 'order' | 'visibility'; /** * Defines the various options to define if a given part from the data grid configuration * will be omited when configuration is persisted. * A truthy or missing value means that the given configuration part will be persisted. * A falsy value means that the configuration part will not be persisted. */ export type GridConfigFilter = { [K in GridConfigPart]?: boolean | Promise<boolean> | Observable<boolean> | (() => boolean | Promise<boolean> | Observable<boolean>); }; /** * Defines the various types of configuration change events the data grid component can emit. */ export type GridEventType = 'filter' | 'sort' | 'pagination' | 'addCustomColumn' | 'removeCustomColumn' | 'reorderColumn' | 'changeColumnVisibility'; /** * Marks classes able to provide grid configuration context data. */ export interface GridConfigContextProvider { getGridConfigContext(): GridConfigContext; } //# sourceMappingURL=data-grid-configuration.model.d.ts.map