UNPKG

@kephas/angular

Version:

Provides integration capabilities with Angular.

149 lines (148 loc) 5.07 kB
import { ElementRef, ViewContainerRef, ChangeDetectorRef, SimpleChanges, OnInit, OnChanges, AfterViewInit, Type, Provider, QueryList, OnDestroy } from '@angular/core'; import { Logger } from '@kephas/core'; import { Notification } from '@kephas/ui'; /** * Provides base functionality for a widget. * * @export * @class WidgetBase */ export declare abstract class WidgetBase implements OnInit, AfterViewInit, OnChanges, OnDestroy { readonly elementRef: ElementRef; readonly viewContainerRef: ViewContainerRef; /** * Gets the logger. * * @protected * @type {Logger} * @memberof ValueEditorBase */ protected readonly logger: Logger; /** * Gets the notification service. * * @protected * @type {Notification} * @memberof ValueEditorBase */ protected readonly notification: Notification; /** * Gets the change detector service. * * @protected * @type {ChangeDetectorRef} * @memberof ValueEditorBase */ protected readonly changeDetector: ChangeDetectorRef; private _isVisible; private _readonly; private _childWidgets?; /** * Creates an instance of WidgetBase. * @param {ElementRef} elementRef The element reference. * @param {ViewContainerRef} viewContainerRef The view container reference. * @memberof WidgetBase */ constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef); /** * Gets or sets the child editors query. * * @readonly * @type {QueryList<EditorBase<any>>} * @memberof EditorBase */ get childWidgets(): QueryList<WidgetBase>; set childWidgets(value: QueryList<WidgetBase>); /** * Gets or sets a value indicating whether the widget is visible. * * @readonly * @type {boolean} * @memberof WidgetBase */ get isVisible(): boolean; set isVisible(value: boolean); /** * Gets or sets a value indicating whether the editor allows edits or not. * * @readonly * @type {boolean} * @memberof EditorBase */ get readonly(): boolean; set readonly(value: boolean); /** * A callback method that is invoked immediately after the * default change detector has checked the directive's * data-bound properties for the first time, * and before any of the view or content children have been checked. * It is invoked only once when the directive is instantiated. * * @memberof WidgetBase */ ngOnInit(): void; /** * A callback method that is invoked immediately after * Angular has completed initialization of a component's view. * It is invoked only once when the view is instantiated. * * @memberof WidgetBase */ ngAfterViewInit(): void; /** * A callback method that is invoked immediately after the * default change detector has checked data-bound properties * if at least one has changed, and before the view and content * children are checked. * * @param changes The changed properties. * @memberof WidgetBase */ ngOnChanges(changes: SimpleChanges): void; /** * A callback method that performs custom clean-up, invoked immediately * after a directive, pipe, or service instance is destroyed. */ ngOnDestroy(): void; /** * When overridden in a derived class, this method is called when the read only state changes. * * @protected * @param {boolean} oldValue The old value. * @param {boolean} newValue The new value. * * @memberof WidgetBase */ protected onReadOnlyChanged(oldValue: boolean, newValue: boolean): void; /** * When overridden in a derived class, this method is called when the child widgets query changed. * * @protected * @param {QueryList<EditorBase<any>>} oldValue The old query. * @param {QueryList<EditorBase<any>>} newValue The new query. * * @memberof EditorBase */ protected onChildWidgetsChanged(oldValue?: QueryList<WidgetBase>, newValue?: QueryList<WidgetBase>): void; } /** * This function provides the component as a WidgetBase, * to be able to import it over this base class instead of over its own class. * * For example, use it as @ViewChild(WidgetBase) or @ViewChildren(WidgetBase). * * @export * @param {Type<any>} componentType The component type. * @returns {Provider} The provider. */ export declare function provideWidget(componentType: Type<any>): Provider; /** * This function provides the component as a NG_VALUE_ACCESSOR. * Thus, it is possible to bind it like this: * <my-component [(ngModel)]="boundProperty"></my-component> * * @export * @param {Type<any>} componentType The component type. * @returns {Provider} The provider. */ export declare function provideValueAccessor(componentType: Type<any>): Provider;