UNPKG

22.9 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../../../src/component-loader/bs-component-ref.class.ts","../../../../src/component-loader/content-ref.class.ts","../../../../src/component-loader/component-loader.class.ts","../../../../src/component-loader/component-loader.factory.ts"],"names":["nodes","viewRef","componentRef","this","ComponentLoader","_viewContainerRef","_renderer","_elementRef","_injector","_componentFactoryResolver","_ngZone","_applicationRef","_posService","onBeforeShow","EventEmitter","onShown","onBeforeHide","onHidden","_providers","_isHiding","containerDefaultSelector","_listenOpts","_globalListener","Function","prototype","Object","defineProperty","_componentRef","attach","compType","_componentFactory","resolveComponentFactory","to","container","position","opts","attachment","target","provide","provider","push","show","_subscribePositioning","_innerComponent","emit","_contentRef","_getContentRef","content","context","initialState","injector","Injector","create","providers","parent","attachView","hostView","instance","assign","ElementRef","nativeElement","appendChild","location","document","selectedElement","querySelector","parentElement","changeDetectorRef","markForCheck","detectChanges","id","_registerOutsideClick","hide","deletePositionElement","componentEl","parentNode","removeChild","_a","destroy","_b","remove","indexOf","_c","_removeGlobalListener","toggle","isShown","dispose","_unsubscribePositioning","_unregisterListenersFn","listen","listenOpts","_this","triggers","outsideClick","outsideEsc","registerHide","listenToTriggersV2","attachInline","vRef","template","_inlineViewRef","createEmbeddedView","target_1","setTimeout","registerOutsideClick","targets","registerEscClick","getInnerComponent","_zoneSubscription","subscribe","element","appendToBody","onStable","calcPosition","unsubscribe","ContentRef","TemplateRef","_viewRef","rootNodes","contentCmptFactory","modalContentInjector","createText","ComponentLoaderFactory","createLoader","Injectable","args","providedIn","ComponentFactoryResolver","NgZone","PositioningService","ApplicationRef"],"mappings":"2hBAEA,eCYE,SAEEA,EACAC,EAEAC,GAEAC,KAAKH,MAAQA,EACbG,KAAKF,QAAUA,EACfE,KAAKD,aAAeA,gBCiDtB,SAAAE,EACUC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAPAT,KAAAE,kBAAAA,EACAF,KAAAG,UAAAA,EACAH,KAAAI,YAAAA,EACA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C,OAHA/F,OAAOiC,OAAOxD,EAAauD,SAAUR,GACrC9C,KAAKQ,gBAAgB4C,WAAWrD,EAAasD,UAEtC,IAAI2D,EACT,CAAC,CAACjH,EAAa4D,SAASF,gBACxB1D,EAAasD,SACbtD,GAIJ,IAAMF,EAAQG,KAAKG,UACf,CAACH,KAAKG,UAAUmH,WAAW,GAAG1E,IAC9B,GACJ,OAAO,IAAIoE,EAAW,CAACnH,uBChazB,SAAA0H,EAAoBjH,EACAC,EACAF,EACAI,EACAD,GAJAR,KAAAM,0BAAAA,EACAN,KAAAO,QAAAA,EACAP,KAAAK,UAAAA,EACAL,KAAAS,YAAAA,EACAT,KAAAQ,gBAAAA,SAQpB+G,EAAAlG,UAAAmG,aAAA,SAAgBpH,EACAF,EACAC,GACd,OAAO,IAAIF,EACTC,EACAC,EACAC,EACAJ,KAAKK,UACLL,KAAKM,0BACLN,KAAKO,QACLP,KAAKQ,gBACLR,KAAKS,oRAzBVgH,EAAAA,WAAUC,KAAA,CAAC,CAACC,WAAY,oDANPC,EAAAA,gCAChBC,EAAAA,cADkE7E,EAAAA,gBAI3D8E,EAAAA,0BAJPC,EAAAA","sourcesContent":["import { TemplateRef, ViewContainerRef } from '@angular/core';\n\nexport class BsComponentRef<T> {\n templateRef?: TemplateRef<T>;\n viewContainer?: ViewContainerRef;\n}\n","/**\n * @copyright Valor Software\n * @copyright Angular ng-bootstrap team\n */\n\nimport { ComponentRef, ViewRef } from '@angular/core';\n\nexport class ContentRef {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nodes: any[];\n viewRef?: ViewRef;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n componentRef?: ComponentRef<any>;\n\n constructor(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nodes: any[],\n viewRef?: ViewRef,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n componentRef?: ComponentRef<any>\n ) {\n this.nodes = nodes;\n this.viewRef = viewRef;\n this.componentRef = componentRef;\n }\n}\n","// todo: add delay support\n// todo: merge events onShow, onShown, etc...\n// todo: add global positioning configuration?\nimport {\n ApplicationRef,\n ComponentFactory,\n ComponentFactoryResolver,\n ComponentRef,\n ElementRef,\n EmbeddedViewRef,\n EventEmitter,\n Injector,\n NgZone,\n Renderer2,\n StaticProvider,\n TemplateRef,\n Type,\n ViewContainerRef\n} from '@angular/core';\n\nimport { PositioningOptions, PositioningService } from 'ngx-bootstrap/positioning';\n\nimport { listenToTriggersV2, registerEscClick, registerOutsideClick } from 'ngx-bootstrap/utils';\nimport { Subscription } from 'rxjs';\n\nimport { ContentRef } from './content-ref.class';\nimport { ListenOptions } from './listen-options.model';\n\nexport class ComponentLoader<T> {\n onBeforeShow = new EventEmitter();\n onShown = new EventEmitter();\n onBeforeHide = new EventEmitter();\n onHidden = new EventEmitter();\n\n instance?: T;\n _componentRef?: ComponentRef<T>;\n _inlineViewRef?: EmbeddedViewRef<T>;\n\n private _providers: StaticProvider[] = [];\n private _componentFactory?: ComponentFactory<T>;\n private _zoneSubscription?: Subscription;\n private _contentRef?: ContentRef;\n private _innerComponent?: ComponentRef<T>;\n\n private _unregisterListenersFn?: () => void;\n private _isHiding = false;\n /**\n * Placement of a component. Accepts: \"top\", \"bottom\", \"left\", \"right\"\n */\n private attachment?: string;\n /**\n * A selector specifying the element the popover should be appended to.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private container: string | ElementRef | any;\n /**\n * A selector used if container element was not found\n */\n private containerDefaultSelector = 'body';\n /**\n * Specifies events that should trigger. Supports a space separated list of\n * event names.\n */\n private triggers?: string;\n private _listenOpts: ListenOptions = {};\n private _globalListener = Function.prototype;\n\n /**\n * Do not use this directly, it should be instanced via\n * `ComponentLoadFactory.attach`\n * @internal\n */\n public constructor(\n private _viewContainerRef: ViewContainerRef | undefined,\n private _renderer: Renderer2 | undefined,\n private _elementRef: ElementRef | undefined,\n private _injector: Injector,\n private _componentFactoryResolver: ComponentFactoryResolver,\n private _ngZone: NgZone,\n private _applicationRef: ApplicationRef,\n private _posService: PositioningService\n ) {\n }\n\n get isShown(): boolean {\n if (this._isHiding) {\n return false;\n }\n\n return !!this._componentRef;\n }\n\n attach(compType: Type<T>): ComponentLoader<T> {\n this._componentFactory = this._componentFactoryResolver\n .resolveComponentFactory<T>(compType);\n\n return this;\n }\n\n // todo: add behaviour: to target element, `body`, custom element\n to(container?: string | ElementRef): ComponentLoader<T> {\n this.container = container || this.container;\n\n return this;\n }\n\n position(opts?: PositioningOptions): ComponentLoader<T> {\n if (!opts) {\n return this;\n }\n\n this.attachment = opts.attachment || this.attachment;\n this._elementRef = (opts.target as ElementRef) || this._elementRef;\n\n return this;\n }\n\n provide(provider: StaticProvider): ComponentLoader<T> {\n this._providers.push(provider);\n\n return this;\n }\n\n // todo: appendChild to element or document.querySelector(this.container)\n\n show(opts: {\n content?: string | TemplateRef<unknown>;\n context?: unknown;\n initialState?: unknown;\n [key: string]: unknown;\n id?: number | string;\n } = {}\n ): ComponentRef<T> | undefined {\n\n this._subscribePositioning();\n this._innerComponent = void 0;\n\n if (!this._componentRef) {\n this.onBeforeShow.emit();\n this._contentRef = this._getContentRef(opts.content, opts.context, opts.initialState);\n\n const injector = Injector.create({\n providers: this._providers,\n parent: this._injector\n });\n\n if (!this._componentFactory) {\n return;\n }\n\n this._componentRef = this._componentFactory.create(injector, this._contentRef.nodes);\n\n this._applicationRef.attachView(this._componentRef.hostView);\n // this._componentRef = this._viewContainerRef\n // .createComponent(this._componentFactory, 0, injector, this._contentRef.nodes);\n this.instance = this._componentRef.instance;\n\n Object.assign(this._componentRef.instance, opts);\n\n if (this.container instanceof ElementRef) {\n this.container.nativeElement.appendChild(\n this._componentRef.location.nativeElement\n );\n }\n\n if (typeof this.container === 'string' && typeof document !== 'undefined') {\n const selectedElement = document.querySelector(this.container) ||\n document.querySelector(this.containerDefaultSelector);\n\n if (!selectedElement) {\n return;\n }\n\n selectedElement.appendChild(this._componentRef.location.nativeElement);\n }\n\n if (\n !this.container &&\n this._elementRef &&\n this._elementRef.nativeElement.parentElement\n ) {\n this._elementRef.nativeElement.parentElement.appendChild(\n this._componentRef.location.nativeElement\n );\n }\n\n // we need to manually invoke change detection since events registered\n // via\n // Renderer::listen() are not picked up by change detection with the\n // OnPush strategy\n if (this._contentRef.componentRef) {\n this._innerComponent = this._contentRef.componentRef.instance;\n this._contentRef.componentRef.changeDetectorRef.markForCheck();\n this._contentRef.componentRef.changeDetectorRef.detectChanges();\n }\n this._componentRef.changeDetectorRef.markForCheck();\n this._componentRef.changeDetectorRef.detectChanges();\n\n\n this.onShown.emit(opts.id ? { id: opts.id } : this._componentRef.instance);\n }\n\n this._registerOutsideClick();\n\n return this._componentRef;\n }\n\n hide(id?: number | string): ComponentLoader<T> {\n if (!this._componentRef) {\n return this;\n }\n\n this._posService.deletePositionElement(this._componentRef.location);\n\n this.onBeforeHide.emit(this._componentRef.instance);\n\n const componentEl = this._componentRef.location.nativeElement;\n componentEl.parentNode.removeChild(componentEl);\n if (this._contentRef?.componentRef) {\n this._contentRef.componentRef.destroy();\n }\n\n if (this._viewContainerRef && this._contentRef?.viewRef) {\n this._viewContainerRef.remove(\n this._viewContainerRef.indexOf(this._contentRef.viewRef)\n );\n }\n if (this._contentRef?.viewRef) {\n this._contentRef.viewRef.destroy();\n }\n\n this._contentRef = void 0;\n this._componentRef = void 0;\n this._removeGlobalListener();\n\n this.onHidden.emit(id ? { id } : null);\n\n return this;\n }\n\n toggle(): void {\n if (this.isShown) {\n this.hide();\n\n return;\n }\n\n this.show();\n }\n\n dispose(): void {\n if (this.isShown) {\n this.hide();\n }\n\n this._unsubscribePositioning();\n\n if (this._unregisterListenersFn) {\n this._unregisterListenersFn();\n }\n }\n\n listen(listenOpts: ListenOptions): ComponentLoader<T> {\n this.triggers = listenOpts.triggers || this.triggers;\n this._listenOpts.outsideClick = listenOpts.outsideClick;\n this._listenOpts.outsideEsc = listenOpts.outsideEsc;\n listenOpts.target = listenOpts.target || this._elementRef?.nativeElement;\n\n const hide = (this._listenOpts.hide = () =>\n listenOpts.hide ? listenOpts.hide() : void this.hide());\n const show = (this._listenOpts.show = (registerHide) => {\n listenOpts.show ? listenOpts.show(registerHide) : this.show(registerHide);\n registerHide();\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const toggle = (registerHide: any) => {\n this.isShown ? hide() : show(registerHide);\n };\n\n if (this._renderer) {\n this._unregisterListenersFn = listenToTriggersV2(this._renderer, {\n target: listenOpts.target,\n triggers: listenOpts.triggers,\n show,\n hide,\n toggle\n });\n }\n\n return this;\n }\n\n _removeGlobalListener() {\n if (this._globalListener) {\n this._globalListener();\n this._globalListener = Function.prototype;\n }\n }\n\n attachInline(\n vRef: ViewContainerRef | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n template: TemplateRef<any> | undefined\n ): ComponentLoader<T> {\n if (vRef && template) {\n this._inlineViewRef = vRef.createEmbeddedView(template);\n }\n\n return this;\n }\n\n _registerOutsideClick(): void {\n if (!this._componentRef || !this._componentRef.location) {\n return;\n }\n // why: should run after first event bubble\n if (this._listenOpts.outsideClick) {\n const target = this._componentRef.location.nativeElement;\n setTimeout(() => {\n if (this._renderer && this._elementRef) {\n this._globalListener = registerOutsideClick(this._renderer, {\n targets: [target, this._elementRef.nativeElement],\n outsideClick: this._listenOpts.outsideClick,\n hide: () => this._listenOpts.hide && this._listenOpts.hide()\n });\n }\n });\n }\n if (this._listenOpts.outsideEsc && this._renderer && this._elementRef) {\n const target = this._componentRef.location.nativeElement;\n this._globalListener = registerEscClick(this._renderer, {\n targets: [target, this._elementRef.nativeElement],\n outsideEsc: this._listenOpts.outsideEsc,\n hide: () => this._listenOpts.hide && this._listenOpts.hide()\n });\n }\n }\n\n getInnerComponent(): ComponentRef<T> | undefined {\n return this._innerComponent;\n }\n\n private _subscribePositioning(): void {\n if (this._zoneSubscription || !this.attachment) {\n return;\n }\n\n this.onShown.subscribe(() => {\n this._posService.position({\n element: this._componentRef?.location,\n target: this._elementRef,\n attachment: this.attachment,\n appendToBody: this.container === 'body'\n });\n });\n\n this._zoneSubscription = this._ngZone.onStable.subscribe(() => {\n if (!this._componentRef) {\n return;\n }\n\n this._posService.calcPosition();\n });\n }\n\n private _unsubscribePositioning(): void {\n if (!this._zoneSubscription) {\n return;\n }\n\n this._zoneSubscription.unsubscribe();\n this._zoneSubscription = void 0;\n }\n\n private _getContentRef(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: string | TemplateRef<any> | any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n context?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n initialState?: any\n ): ContentRef {\n if (!content) {\n return new ContentRef([]);\n }\n\n if (content instanceof TemplateRef) {\n if (this._viewContainerRef) {\n const _viewRef = this._viewContainerRef\n .createEmbeddedView<TemplateRef<T>>(content, context);\n _viewRef.markForCheck();\n\n return new ContentRef([_viewRef.rootNodes], _viewRef);\n }\n const viewRef = content.createEmbeddedView({});\n this._applicationRef.attachView(viewRef);\n\n return new ContentRef([viewRef.rootNodes], viewRef);\n }\n\n if (typeof content === 'function') {\n const contentCmptFactory = this._componentFactoryResolver.resolveComponentFactory(\n content\n );\n\n const modalContentInjector = Injector.create({\n providers: this._providers,\n parent: this._injector\n });\n\n const componentRef = contentCmptFactory.create(modalContentInjector);\n Object.assign(componentRef.instance, initialState);\n this._applicationRef.attachView(componentRef.hostView);\n\n return new ContentRef(\n [[componentRef.location.nativeElement]],\n componentRef.hostView,\n componentRef\n );\n }\n\n const nodes = this._renderer\n ? [this._renderer.createText(`${content}`)]\n : [];\n return new ContentRef([nodes]);\n }\n}\n","import {\n ApplicationRef, ComponentFactoryResolver, ElementRef, Injectable, Injector,\n NgZone, Renderer2, ViewContainerRef\n} from '@angular/core';\nimport { ComponentLoader } from './component-loader.class';\nimport { PositioningService } from 'ngx-bootstrap/positioning';\n\n@Injectable({providedIn: 'root'})\nexport class ComponentLoaderFactory {\n constructor(private _componentFactoryResolver: ComponentFactoryResolver,\n private _ngZone: NgZone,\n private _injector: Injector,\n private _posService: PositioningService,\n private _applicationRef: ApplicationRef) {}\n\n /**\n *\n * @param _elementRef\n * @param _viewContainerRef\n * @param _renderer\n */\n createLoader<T>(_elementRef?: ElementRef,\n _viewContainerRef?: ViewContainerRef,\n _renderer?: Renderer2): ComponentLoader<T> {\n return new ComponentLoader<T>(\n _viewContainerRef,\n _renderer,\n _elementRef,\n this._injector,\n this._componentFactoryResolver,\n this._ngZone,\n this._applicationRef,\n this._posService\n );\n }\n}\n"]}
\No newline at end of file