ng-hub-ui-portal
Version:
A flexible Angular portal library for dynamic content rendering with advanced positioning and interaction control
73 lines (72 loc) • 3.71 kB
TypeScript
import { EventEmitter, Injector } from '@angular/core';
import { HubPortalOptions } from './portal-config';
import { HubPortalRef } from './portal-ref';
import * as i0 from "@angular/core";
export declare class HubPortalStack {
private _applicationRef;
private _injector;
private _environmentInjector;
private _document;
private _scrollBar;
private _activeWindowCmptHasChanged;
private _ariaHiddenValues;
private _scrollBarRestoreFn;
private _portalRefs;
private _windowCmpts;
private _activeInstances;
constructor();
private _restoreScrollBar;
private _hideScrollBar;
open(contentInjector: Injector, content: any, options: HubPortalOptions): HubPortalRef;
/**
* Toggles a portal by dismissing all existing portals and waiting for them to be hidden
* before showing the new one.
*
* @param contentInjector - The injector to use for dependency injection
* @param content - The content to display (component, template, or string)
* @param options - Portal configuration options
* @returns A reference to the newly created portal
*/
toggle(contentInjector: Injector, content: any, options: HubPortalOptions): HubPortalRef;
get activeInstances(): EventEmitter<HubPortalRef[]>;
dismissAll(reason?: any): void;
hasOpenPortals(): boolean;
private _createWindowComponent;
private _attachWindowComponent;
private _getContentRef;
private _createFromTemplateRef;
private _createFromString;
private _createFromComponent;
private _setAriaHidden;
private _revertAriaHidden;
private _registerPortalRef;
private _registerWindowCmpt;
/**
* Attaches click event listeners to elements within a container based on a specified dismiss selector to dismiss a portal.
*
* @param {HTMLElement} container - The `container` parameter is an HTMLElement that represents the DOM element which contains the
* portal content.
* @param {HubActivePortal} context - The `context` parameter in the `_addDismissEventListener` function refers to the active portal
* instance that is being displayed. It is used to call the `dismiss` method on the portal instance when a dismissible element is
* clicked.
* @param {HubPortalOptions} options - The `options` parameter is an object that contains configuration options for the portal. It
* may include properties such as `dismissSelector`, which is used to specify a CSS selector for elements that, when clicked, will
* dismiss the portal by calling the `dismiss` method on the `context` object.
*/
private _addDismissEventListener;
/**
* Attaches click event listeners to elements matching a specified selector to close a portal window.
*
* @param {HTMLElement} container - The `container` parameter is an HTMLElement that represents the DOM element which contains the
* portal content.
* @param {HubActivePortal} context - The `context` parameter in the `_addCloseEventListener` function is of type `HubActivePortal`.
* It is used to reference the active portal instance within the function and call the `close()` method on it when a close event is
* triggered.
* @param {HubPortalOptions} options - The `options` parameter is an object that contains configuration options for the portal. It
* may include properties such as `closeSelector`, which is used to specify the selector for elements that can trigger the portal
* to close when clicked.
*/
private _addCloseEventListener;
static ɵfac: i0.ɵɵFactoryDeclaration<HubPortalStack, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HubPortalStack>;
}