UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

96 lines 3.58 kB
import { InjectionToken, Injector } from '@angular/core'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { ExtensionFactory, GenericHookType, ExtensionPointForPlugins, GenericHookOptions } from '../common/extension-hooks'; import { OptionsService } from '../common/options.service'; import { PluginsResolveService } from '../plugins/plugins-resolve.service'; import { Tab } from './tab.model'; 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 TabExtension = Tab | Tab[] | ExtensionFactory<Tab>; /** * A hook to use for Multi Provider extension. * @deprecated Consider using the `hookTab` function instead. */ export declare const HOOK_TABS: InjectionToken<TabExtension[]>; /** * You can either provide a single `Tab` as parameter: * ```typescript * hookTab(...) * ``` * * Or an array to directly register multiple: * ```typescript * hookTab([...]) * ``` * * Or you provide an Service that implements `ExtensionFactory<Tab>` * ```typescript * export class MyTabFactory implements ExtensionFactory<Tab> {...} * ... * hookTab(MyTabFactory) * ``` * A typed alternative to `HOOK_TABS`. * @param tabs The `Tab`'s or `ExtensionFactory` to be provided. * @returns An `Provider` to be provided in your module. */ export declare function hookTab(tabs: GenericHookType<Tab>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider; /** * A service which defines the used tabs. */ export declare class TabsService extends ExtensionPointForPlugins<Tab> { private router; private translateService; private options; items$: Observable<Tab[]>; orientation$: Observable<'vertical' | 'horizontal'>; constructor(rootInjector: Injector, router: Router, translateService: TranslateService, options: OptionsService, plugins: PluginsResolveService); prepareTabs(tabs: any): any[]; sortTabs(tabs: any): any[]; /** * Returns the current state. * @readonly * @returns The current set of actions. */ get state(): Set<Tab>; /** * Adds a new item to tabs and emits state change * @param item The item to add. */ add(item: Tab): void; /** * Removes a tab and emits a state change. * @param item The item to remove. */ remove(item: Tab): void; get firstTab$(): Observable<Tab>; /** * Checks if at least one of the tabs is available. * @param tabLabels The array of tab labels to check. * @returns Returns true if at least one of the tabs is available. */ areAvailable(tabLabels: string[]): boolean; protected setupItemsObservable(): Observable<Tab[]>; private sort; static ɵfac: i0.ɵɵFactoryDeclaration<TabsService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TabsService>; } //# sourceMappingURL=tabs.service.d.ts.map