|
| 1 | +import { Directive, Injectable, NgModule, TemplateRef, ViewContainerRef } from '@angular/core'; |
| 2 | +import { CdkPortal, ComponentPortal, Portal, PortalModule, TemplatePortal } from '@angular/cdk/portal'; |
| 3 | +import { |
| 4 | + ComponentType, |
| 5 | + ConnectedOverlayPositionChange, |
| 6 | + ConnectedPosition, |
| 7 | + ConnectionPositionPair, |
| 8 | + FlexibleConnectedPositionStrategy, |
| 9 | + GlobalPositionStrategy, |
| 10 | + Overlay, |
| 11 | + OverlayContainer, |
| 12 | + OverlayModule, |
| 13 | + OverlayPositionBuilder, |
| 14 | + OverlayRef, |
| 15 | + PositionStrategy, |
| 16 | +} from '@angular/cdk/overlay'; |
| 17 | +import { Platform } from '@angular/cdk/platform'; |
| 18 | + |
| 19 | + |
| 20 | +@Directive({ selector: '[nbPortal]' }) |
| 21 | +export class NbPortalDirective extends CdkPortal { |
| 22 | +} |
| 23 | + |
| 24 | +@Injectable() |
| 25 | +export class NbOverlayService extends Overlay { |
| 26 | +} |
| 27 | + |
| 28 | +@Injectable() |
| 29 | +export class NbPlatform extends Platform { |
| 30 | +} |
| 31 | + |
| 32 | +@Injectable() |
| 33 | +export class NbOverlayPositionBuilder extends OverlayPositionBuilder { |
| 34 | +} |
| 35 | + |
| 36 | +export class NbComponentPortal<T = any> extends ComponentPortal<T> { |
| 37 | +} |
| 38 | + |
| 39 | +export class NbTemplatePortal<T = any> extends TemplatePortal<T> { |
| 40 | + constructor(template: TemplateRef<T>, viewContainerRef?: ViewContainerRef, context?: T) { |
| 41 | + super(template, viewContainerRef, context); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +export class NbOverlayContainer extends OverlayContainer { |
| 46 | +} |
| 47 | + |
| 48 | +export class NbFlexibleConnectedPositionStrategy extends FlexibleConnectedPositionStrategy { |
| 49 | +} |
| 50 | + |
| 51 | +export type NbPortal<T = any> = Portal<T>; |
| 52 | +export type NbOverlayRef = OverlayRef; |
| 53 | +export type NbComponentType<T = any> = ComponentType<T>; |
| 54 | +export type NbGlobalPositionStrategy = GlobalPositionStrategy; |
| 55 | +export type NbPositionStrategy = PositionStrategy; |
| 56 | +export type NbConnectedPosition = ConnectedPosition; |
| 57 | +export type NbConnectedOverlayPositionChange = ConnectedOverlayPositionChange; |
| 58 | +export type NbConnectionPositionPair = ConnectionPositionPair; |
| 59 | + |
| 60 | +const CDK_MODULES = [OverlayModule, PortalModule]; |
| 61 | + |
| 62 | +const CDK_PROVIDERS = [ |
| 63 | + NbOverlayService, |
| 64 | + NbPlatform, |
| 65 | + NbOverlayPositionBuilder, |
| 66 | +]; |
| 67 | + |
| 68 | +/** |
| 69 | + * This module helps us to keep all angular/cdk deps inside our cdk module via providing aliases. |
| 70 | + * Approach will help us move cdk in separate npm package and refactor nebular/theme code. |
| 71 | + * */ |
| 72 | +@NgModule({ |
| 73 | + imports: [...CDK_MODULES], |
| 74 | + exports: [ |
| 75 | + ...CDK_MODULES, |
| 76 | + NbPortalDirective, |
| 77 | + ], |
| 78 | + declarations: [NbPortalDirective], |
| 79 | + providers: [...CDK_PROVIDERS], |
| 80 | +}) |
| 81 | +export class NbCdkMappingModule { |
| 82 | +} |
0 commit comments