carbon-components-angular
Version:
Next generation components
123 lines (119 loc) • 4.4 kB
TypeScript
/*!
*
* Neutrino v0.0.0 | dialog.service.d.ts
*
* Copyright 2014, 2018 IBM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EventEmitter, Injector, ComponentRef, ComponentFactory, ComponentFactoryResolver, ViewContainerRef } from "@angular/core";
import { DialogConfig } from "./dialog-config.interface";
import { PlaceholderService } from "./../placeholder/placeholder.module";
/**
* `Dialog` object to be injected into other components.
* @export
* @class DialogService
*/
export declare class DialogService {
protected componentFactoryResolver: ComponentFactoryResolver;
protected injector: Injector;
protected placeholderService: PlaceholderService;
/**
* Used in `singletonClickListen`, don't count on its existence and values.
*/
private static listeningForBodyClicks;
/**
* Reflects the open or closed state of the `Dialog`.
* @memberof DialogService
*/
isOpen: boolean;
/**
* To be used to create the component using metadata.
* @type {ComponentFactory<any>}
* @memberof DialogService
*/
componentFactory: ComponentFactory<any>;
/**
* To emit the `Dialog` closing event.
* @type {EventEmitter<any>}
* @memberof DialogService
*/
onClose: EventEmitter<any>;
/**
* Holds reference to the created `Dialog` component after creation.
* @type {ComponentRef<any>}
* @memberof DialogService
*/
dialogRef: ComponentRef<any>;
/**
* Emits the state `true` if the Dialog is closed, false if `Dialog`
* is opened/viewable.
* @type {EventEmitter<any>}
* @memberof DialogService
*/
isClosed: EventEmitter<any>;
/**
* To watch the event that closes the `Dialog`.
* @private
* @type {Subscription}
* @memberof DialogService
*/
private dialogSubscription;
/**
* Creates an instance of `DialogService`.
* @param {ComponentFactoryResolver} componentFactoryResolver
* @param {Injector} injector
* @memberof DialogService
*/
constructor(componentFactoryResolver: ComponentFactoryResolver, injector: Injector, placeholderService: PlaceholderService);
/**
* Uses module `componentFactory` to create the `Dialog` component.
* @param {any} component
* @memberof DialogService
*/
create(component: any): void;
/**
* Toggles between `Dialog` open/close states.
* @param {ViewContainerRef} viewContainer
* @param {DialogConfig} dialogConfig
* @memberof DialogService
*/
toggle(viewContainer: ViewContainerRef, dialogConfig: DialogConfig): void;
/**
* If `dialogRef` is defined, the Dialog is already open. If
* `dialogRef` is undefined, we create the `Dialog` component and reference to it.
* A subscription is created to track if the `Dialog` should close.
* @param {ViewContainerRef} viewContainer
* @param {DialogConfig} dialogConfig
* @memberof DialogService
*/
open(viewContainer: ViewContainerRef, dialogConfig: DialogConfig): this;
/**
* On close of `Dialog` item, sets focus back to previous item, unsets
* the current `dialogRef` item. Unsubscribes to the event of `Dialog` close.
* @param {ViewContainerRef} viewContainer
* @param {any} [evt]
* @memberof DialogService
*/
close(viewContainer: ViewContainerRef): void;
/**
* Fix for safari hijacking clicks.
*
* Runs on `ngOnInit` of every dialog. Ensures we don't have multiple listeners
* because having many of them could degrade performance in certain cases (and is
* not necessary for our use case)
*
* This is an internally used function, can change at any point (even get removed)
* and changes to it won't be considered a breaking change. Use at your own risk.
*/
singletonClickListen(): void;
}