ng-hub-ui-portal
Version:
A flexible Angular portal library for dynamic content rendering with advanced positioning and interaction control
104 lines (103 loc) • 3.65 kB
TypeScript
import { ComponentRef } from '@angular/core';
import { ContentRef } from 'ng-hub-ui-utils';
import { Observable } from 'rxjs';
import { HubPortalUpdatableOptions } from './portal-config';
import { HubPortalWindow } from './portal-window';
/**
* A reference to the currently opened (active) portal.
*
* Instances of this class can be injected into your component passed as portal content.
* So you can `.update()`, `.close()` or `.dismiss()` the portal window from your component.
*/
export declare class HubActivePortal {
/**
* Updates options of an opened portal.
*
* @since 14.2.0
*/
update(options: HubPortalUpdatableOptions): void;
/**
* Closes the portal with an optional `result` value.
*
* The `HubPortalRef.result` promise will be resolved with the provided value.
*/
close(result?: any): void;
/**
* Dismisses the portal with an optional `reason` value.
*
* The `HubPortalRef.result` promise will be rejected with the provided value.
*/
dismiss(reason?: any): void;
}
/**
* A reference to the newly opened portal returned by the `HubPortal.open()` method.
*/
export declare class HubPortalRef {
private _windowCmptRef;
private _contentRef;
private _beforeDismiss?;
private _closed;
private _dismissed;
private _hidden;
private _resolve;
private _reject;
private _applyWindowOptions;
/**
* Updates options of an opened portal.
*
* @since 14.2.0
*/
update(options: HubPortalUpdatableOptions): void;
/**
* The instance of a component used for the portal content.
*
* When a `TemplateRef` is used as the content or when the portal is closed, will return `undefined`.
*/
get componentInstance(): any;
/**
* The promise that is resolved when the portal is closed and rejected when the portal is dismissed.
*/
result: Promise<any>;
/**
* The observable that emits when the portal is closed via the `.close()` method.
*
* It will emit the result passed to the `.close()` method.
*/
get closed(): Observable<any>;
/**
* The observable that emits when the portal is dismissed via the `.dismiss()` method.
*
* It will emit the reason passed to the `.dismissed()` method by the user.
*/
get dismissed(): Observable<any>;
/**
* The observable that emits when portal window is closed and animations were finished.
* At this point portal element will be removed from the DOM tree.
*
* This observable will be completed after emitting.
*/
get hidden(): Observable<void>;
/**
* The observable that emits when portal is fully visible and animation was finished.
* Portal DOM element is always available synchronously after calling 'portal.open()' service.
*
* This observable will be completed after emitting.
* It will not emit, if portal is closed before open animation is finished.
*/
get shown(): Observable<void>;
constructor(_windowCmptRef: ComponentRef<HubPortalWindow>, _contentRef: ContentRef, _beforeDismiss?: (() => boolean | Promise<boolean>) | undefined);
/**
* Closes the portal with an optional `result` value.
*
* The `HubMobalRef.result` promise will be resolved with the provided value.
*/
close(result?: any): void;
private _dismiss;
/**
* Dismisses the portal with an optional `reason` value.
*
* The `HubPortalRef.result` promise will be rejected with the provided value.
*/
dismiss(reason?: any): void;
private _removePortalElements;
}