@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
111 lines • 4.08 kB
TypeScript
import { InjectionToken, Injector } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { ExtensionFactory, GenericHookType, ExtensionPointForPlugins, GenericHookOptions } from '../common/extension-hooks';
import { ActionBarItem } from './action-bar.model';
import { PluginsResolveService } from '../plugins/plugins-resolve.service';
import * as i0 from "@angular/core";
/**
* An extension HOOK can use either a pure value:
* ```typescript
* { provide: HOOK_X, useValue: { ...hookValue }, multi: true }
* ```
*
* Or an array to directly register multiple:
* ```typescript
* { provide: HOOK_X, useValue: [{ ...hookValues }], multi: true }
* ```
*
* Or an ExtensionFactory which allows to define a get() function. This function
* gets called on each navigation with the current route and can return values
* async (observable or promise).
* ```typescript
* { provide: HOOK_X, useFactory: { get: (route) => doSomethingAsync(route) }, multi: true }
* ```
*/
export type ActionBarExtension = ActionBarItem | ActionBarItem[] | ExtensionFactory<ActionBarItem>;
/**
* A hook to add ActionBarItems using the multi provider extension concept.
* Consider using the `hookActionBar` function instead.
*
* ```typescript
* providers: [
* {
* provide: HOOK_ACTION_BAR,
* useValue: [{ template: SomeComponent, priority: 10, placement: 'left' } as ActionBarItem],
* multi: true
* }
* ]
* ```
* @deprecated Consider using the `hookActionBar` function instead.
*/
export declare const HOOK_ACTION_BAR: InjectionToken<ActionBarExtension>;
/**
* A hook to add ActionBarItems using the multi provider extension concept.
*
* You can either provide a single `ActionBarItem` as parameter:
* ```typescript
* hookActionBar(...)
* ```
*
* Or an array to directly register multiple:
* ```typescript
* hookActionBar([...])
* ```
*
* Or you provide an Service that implements `ExtensionFactory<ActionBarItem>`
* ```typescript
* export class MyActionBarFactory implements ExtensionFactory<ActionBarItem> {...}
* ...
* hookActionBar(MyActionBarFactory)
* ```
* A typed alternative to `HOOK_ACTION_BAR`.
* @param items The `ActionBarItem`'s or `ExtensionFactory` to be provided.
* @returns An `Provider` to be provided in your module.
*/
export declare function hookActionBar(items: GenericHookType<ActionBarItem>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider;
/**
* A service which defines action-bar items via the multi provider concept.
*
* ```typescript
* // preferred way, multi provider concept:
* providers: [
* {
* provide: HOOK_ACTION_BAR,
* useValue: [{ template: SomeComponent, priority: 10, placement: 'left' } as ActionBarItem],
* multi: true
* }
* ]
*
* // use services:
* this.actionBarService.add({ template: SomeComponent, priority: 10, placement: 'left' });
* ```
*/
export declare class ActionBarService extends ExtensionPointForPlugins<ActionBarItem> {
private router;
/**
* @ignore
*/
constructor(rootInjector: Injector, router: Router, plugins: PluginsResolveService);
/**
* Returns the current state.
* @readonly
* @returns The current set of actions.
*/
get state(): Set<ActionBarItem>;
/**
* Adds a new item to the action bar in the header and emits a state change.
* @param item The item to add.
*/
add(item: ActionBarItem): void;
/**
* Removes an action bar item from the header and emits a state change.
* @param item The item to remove.
*/
remove(item: ActionBarItem): void;
protected setupItemsObservable(): Observable<ActionBarItem[]>;
protected pickItemFromGroup(groupedItems: ActionBarItem[]): ActionBarItem;
static ɵfac: i0.ɵɵFactoryDeclaration<ActionBarService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ActionBarService>;
}
//# sourceMappingURL=action-bar.service.d.ts.map