UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

94 lines 3.46 kB
import { InjectionToken, Injector, Type } from '@angular/core'; import { ExtensionFactory, GenericHookOptions, GenericHookType } from '@c8y/ngx-components'; /** * A hook to add dynamic configurations to any widget configuration. * @deprecated Consider using the `hookWidgetConfig` function instead. */ export declare const HOOK_WIDGET_CONFIG: InjectionToken<WidgetConfigSectionDefinition<any>[]>; /** * 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: [{ ...hookValue1 }, { ...hookValue2 }], 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 WidgetConfigSectionExtension = WidgetConfigSectionDefinition | WidgetConfigSectionDefinition[] | ExtensionFactory<WidgetConfigSectionDefinition>; /** * A hook to add dynamic components to the UI (e.g. widgets). * * You can either provide a single `DynamicComponentDefinition` as parameter: * ```typescript * hookWidgetConfig(...) * ``` * * Or an array to directly register multiple: * ```typescript * hookWidgetConfig([...]) * ``` * * Or you provide an Service that implements `ExtensionFactory<DynamicComponentDefinition>` * ```typescript * export class MyDynamicComponentDefinitionFactory implements ExtensionFactory<DynamicComponentDefinition> {...} * ... * hookWidgetConfig(MyDynamicComponentDefinitionFactory) * ``` * A typed alternative to `HOOK_WIDGET_CONFIG`. * @param components The `DynamicComponentDefinition`'s or `ExtensionFactory` to be provided. * @returns An `Provider` to be provided in your module. */ export declare function hookWidgetConfig<T = Type<any>>(components: GenericHookType<WidgetConfigSectionDefinition<T>>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ClassProvider | import("@angular/core").ExistingProvider; export interface WidgetConfigSectionDefinition<T = any> extends WidgetConfigSectionBase<T> { /** * The dynamic component id this configuration applies to. */ widgetId: string; /** * The component to load. */ loadComponent: () => Promise<Type<T>>; } export interface WidgetConfigSection<T = Type<any>> extends WidgetConfigSectionBase<T> { /** * The component to load. */ component: T; } export interface WidgetConfigSectionBase<T> { /** * The label to show as headline of the section */ label: string; /** * The priority. Default settings from hookWidget will have priority 0. */ priority?: number; /** * Defines if the section should be by default expanded or collapsed. */ expanded?: boolean; /** * The initial state. */ initialState?: Partial<T>; /** * The injector to be used. */ injector?: Injector; /** * Additional providers to be used only in scope of the configuration. If same Providers are * provided multiple times, only one is used. */ providers?: Type<unknown>[]; } //# sourceMappingURL=widget-config-hook.model.d.ts.map