import { ComponentRef } from '@angular/core' ; import { Overlay } from '../overlay/index' ; import { Class } from '../framework/utils' ; import { OverlayConfig , ContainerContent } from '../models/tokens' ; import { DialogRef } from '../models/dialog-ref' ; import { ModalControllingContextBuilder } from '../models/overlay-context' ; export function unsupportedDropInError ( dropInName ) { return new Error ( `Unsupported Drop-In ${ dropInName }` ) ; } export abstract class Modal { constructor ( public overlay ) { } alert ( ) { throw unsupportedDropInError ( 'alert' ) ; } prompt ( ) { throw unsupportedDropInError ( 'prompt' ) ; } confirm ( ) { throw unsupportedDropInError ( 'confirm' ) ; } param content param config open ( content , config ? ) { config = config || { } as any ; let dialogs = this . overlay . open ( config , this . constructor ) ; if ( dialogs . length > 1 ) { console . warn ( `Attempt to open more then 1 overlay detected.
      Multiple modal copies are not supported at the moment, 
      only the first viewContainer will display.` ) ; } return this . create ( dialogs [ 0 ] , content ) ; } param dialogRef param type protected abstract create ( dialogRef , type ) ; protected createBackdrop < T > ( dialogRef , BackdropComponent ) { return dialogRef . overlayRef . instance . addComponent < T > ( BackdropComponent ) ; } protected createContainer < T > ( dialogRef , ContainerComponent , content ) { let nodes = dialogRef . overlayRef . instance . getProjectables ( content ) ; return dialogRef . overlayRef . instance . addComponent < T > ( ContainerComponent , nodes ) ; } }