@miracledevs/paradigm-web-angular
Version:
An angular wrapper with base functionality and helper services.
88 lines (87 loc) • 3.23 kB
TypeScript
/*!
* Paradigm Framework - Angular Wrapper
* Copyright (c) 2017 Miracle Devs, Inc
* Licensed under MIT (https://github.com/MiracleDevs/Paradigm.Web.Shared/blob/master/LICENSE)
*/
import { ComponentFactoryResolver, Injector, Type, ComponentRef, ViewContainerRef } from '@angular/core';
import { ModalComponentBase } from '../components/modal-base.component';
import { ArrayList } from '@miracledevs/paradigm-ui-web-shared';
import { ServiceBase } from './base.service';
export declare type ModalResolve<TResult> = (result: TResult) => void;
export declare type ModalReject = (reason: string) => void;
/**
* Represents a modal dialog instance.
* This class lifespan depends on the modal dialog lifespan.
*/
export declare class ModalInstance<TParameters, TResult> {
/**
* A reference to the component ref object.
*/
private innerComponentRef;
/**
* The type of the modal component.
*/
readonly type: Type<ModalComponentBase<TParameters, TResult>>;
/**
* Resolves and finish successfully the modal dialog.
*/
resolve: ModalResolve<TResult>;
/**
* Rejects and finish unsuccessfully the modal dialog.
*/
reject: ModalReject;
/**
* Gets the component ref associated to the modal dialog.
*/
readonly componentRef: ComponentRef<ModalComponentBase<TParameters, TResult>>;
/**
* Creates an instance of @see ModalInstance
* @param type the modal component type.
*/
constructor(type: Type<ModalComponentBase<TParameters, TResult>>);
/**
* Sets the component ref reference.
* @param componentRef the component ref object.
*/
setComponentRef(componentRef: ComponentRef<ModalComponentBase<TParameters, TResult>>): void;
}
export declare class ModalService extends ServiceBase {
private resolver;
private injector;
/**
* A stack of modal instances.
*/
private modalInstances;
/**
* A reference to the view container ref that will hold
* and contain the modal components.
*/
private viewContainer;
/**
* Creates a new instance of @see ModalService
* @param resolver a reference to the component factory resolver,
* @param injector a reference to the DI injector container
*/
constructor(resolver: ComponentFactoryResolver, injector: Injector);
/**
* Sets the view container ref that will hold and contain
* the modal components.
* @param container the view container ref.
*/
setViewContainer(container: ViewContainerRef): void;
/**
* Gets the stack of modal instances.
*/
getModalInstances(): ArrayList<ModalInstance<any, any>>;
/**
* Opens a modal dialog component.
* @param type The modal component type.
* @param parameters the creation parameters to pass to the modal component.
*/
open<TParameters, TResult>(type: Type<ModalComponentBase<TParameters, TResult>>, parameters?: TParameters): Promise<TResult>;
/**
* Removes the modal from the stack of modal instances.
* @param modalInstance the modal that will be removed.
*/
private remove;
}