UNPKG

@nativescript-community/ui-drawer

Version:

Easily add a side drawer (side menu) to your projects.

1 lines 10.5 kB
{"version":3,"file":"nativescript-community-ui-drawer-angular.mjs","sources":["../../../../src/ui-drawer/angular/module.ts","../../../../src/ui-drawer/angular/nativescript-community-ui-drawer-angular.ts"],"sourcesContent":["import { Component, Directive, ElementRef, EmbeddedViewRef, EventEmitter, Inject, Input, NgModule, Output, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { NgView, ViewClassMeta, registerElement } from '@nativescript/angular';\nimport { Drawer } from '@nativescript-community/ui-drawer';\n\nconst LEFTDRAWER: string = 'LeftDrawer';\nconst RIGHTDRAWER: string = 'RightDrawer';\nconst TOPDRAWER: string = 'TopDrawer';\nconst BOTTOMDRAWER: string = 'BottomDrawer';\nconst MAINCONTENT: string = 'MainContent';\n\nexport interface ItemEventArgs {\n object: any;\n view: EmbeddedViewRef<any>;\n returnValue?: boolean;\n}\n\n/**\n * This is the SideDrawer component. It separates your mobile app's screen\n * into a main part and a menu part whereby the menu part is shown upon a swipe\n * gesture using a transition effect.\n */\n@Component({\n selector: 'Drawer',\n template: '<ng-content></ng-content>'\n})\nexport class DrawerComponent {\n public drawer: Drawer;\n public mainTemplate: TemplateRef<ElementRef>;\n public drawerTemplate: TemplateRef<ElementRef>;\n\n private _gestureEnabled: boolean;\n\n constructor(@Inject(ElementRef) public elementRef: ElementRef, @Inject(ViewContainerRef) private viewContainer: ViewContainerRef) {\n this.drawer = this.elementRef.nativeElement;\n }\n\n public get nativeElement(): Drawer {\n return this.drawer;\n }\n\n set gestureEnabled(value: boolean) {\n this._gestureEnabled = value;\n this.updateGestureEnabled();\n }\n\n private updateGestureEnabled() {\n this.drawer.gestureEnabled = this._gestureEnabled;\n }\n}\n\n/**\n * Directive identifying the left drawer\n */\n@Directive({\n selector: '[leftDrawer]'\n})\nexport class LeftDrawerDirective {\n constructor(@Inject(ElementRef) private _elementRef: ElementRef) {\n this._elementRef.nativeElement.id = LEFTDRAWER;\n }\n}\n/**\n * Directive identifying the right drawer\n */\n@Directive({\n selector: '[rightDrawer]'\n})\nexport class RightDrawerDirective {\n constructor(@Inject(ElementRef) private _elementRef: ElementRef) {\n this._elementRef.nativeElement.id = RIGHTDRAWER;\n }\n}\n\n/**\n * Directive identifying the right drawer\n */\n@Directive({\n selector: '[topDrawer]'\n})\nexport class TopDrawerDirective {\n constructor(@Inject(ElementRef) private _elementRef: ElementRef) {\n this._elementRef.nativeElement.id = TOPDRAWER;\n }\n}\n\n/**\n * Directive identifying the right drawer\n */\n@Directive({\n selector: '[bottomDrawer]'\n})\nexport class BottomDrawerDirective {\n constructor(@Inject(ElementRef) private _elementRef: ElementRef) {\n this._elementRef.nativeElement.id = BOTTOMDRAWER;\n }\n}\n\n/**\n * Directive identifying the main content.\n */\n@Directive({\n selector: '[mainContent]'\n})\nexport class MainContentDirective {\n constructor(@Inject(ElementRef) private _elementRef: ElementRef) {\n this._elementRef.nativeElement.id = MAINCONTENT;\n }\n}\n\nconst sideDrawerMeta: ViewClassMeta = {\n insertChild: (parent: NgView, child: NgView) => {\n const drawer = parent as any as Drawer;\n const childView = child;\n\n if (childView.id === MAINCONTENT) {\n drawer.mainContent = childView;\n }\n\n if (childView.id === LEFTDRAWER) {\n drawer.leftDrawer = childView;\n }\n if (childView.id === RIGHTDRAWER) {\n drawer.rightDrawer = childView;\n }\n if (childView.id === TOPDRAWER) {\n drawer.topDrawer = childView;\n }\n if (childView.id === BOTTOMDRAWER) {\n drawer.bottomDrawer = childView;\n }\n },\n removeChild: (parent: NgView, child: NgView) => {\n const drawer = parent as any as Drawer;\n const childView = child;\n\n if (childView.id === MAINCONTENT) {\n drawer.mainContent = null;\n }\n\n if (childView.id === LEFTDRAWER) {\n drawer.leftDrawer = null;\n }\n if (childView.id === RIGHTDRAWER) {\n drawer.rightDrawer = null;\n }\n if (childView.id === TOPDRAWER) {\n drawer.topDrawer = null;\n }\n if (childView.id === BOTTOMDRAWER) {\n drawer.bottomDrawer = null;\n }\n }\n};\n\n/**\n * Directives identifying the Drawer.\n */\nexport const SIDEDRAWER_DIRECTIVES = [LeftDrawerDirective, RightDrawerDirective, TopDrawerDirective, BottomDrawerDirective, MainContentDirective];\n\nregisterElement('Drawer', () => Drawer, sideDrawerMeta);\n\n/**\n * NgModule containing all of the RadSideDrawer directives.\n */\n@NgModule({\n declarations: [DrawerComponent, SIDEDRAWER_DIRECTIVES],\n exports: [DrawerComponent, SIDEDRAWER_DIRECTIVES]\n})\nexport class DrawerModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAIA,MAAM,UAAU,GAAW,YAAY;AACvC,MAAM,WAAW,GAAW,aAAa;AACzC,MAAM,SAAS,GAAW,WAAW;AACrC,MAAM,YAAY,GAAW,cAAc;AAC3C,MAAM,WAAW,GAAW,aAAa;AAQzC;;;;AAIG;MAKU,eAAe,CAAA;AAOe,IAAA,UAAA;AAA0D,IAAA,aAAA;AAN1F,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,cAAc;AAEb,IAAA,eAAe;IAEvB,WAAuC,CAAA,UAAsB,EAAoC,aAA+B,EAAA;QAAzF,IAAU,CAAA,UAAA,GAAV,UAAU;QAAgD,IAAa,CAAA,aAAA,GAAb,aAAa;QAC1G,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa;;AAG/C,IAAA,IAAW,aAAa,GAAA;QACpB,OAAO,IAAI,CAAC,MAAM;;IAGtB,IAAI,cAAc,CAAC,KAAc,EAAA;AAC7B,QAAA,IAAI,CAAC,eAAe,GAAG,KAAK;QAC5B,IAAI,CAAC,oBAAoB,EAAE;;IAGvB,oBAAoB,GAAA;QACxB,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe;;yGArB5C,eAAe,EAAA,EAAA,CAAA,iBAAA,CAOJ,UAAU,CAAA,EAAA,EAAA,CAAA,iBAAA,CAAyC,gBAAgB,CAAA,CAAA,CAA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