UNPKG

@nativescript-community/ui-drawer

Version:

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

232 lines (228 loc) 9.69 kB
import * as i0 from '@angular/core'; import { ElementRef, ViewContainerRef, Component, Inject, Directive, NgModule } from '@angular/core'; import { registerElement } from '@nativescript/angular'; import { Drawer } from '@nativescript-community/ui-drawer'; const _c0 = ["*"]; const LEFTDRAWER = 'LeftDrawer'; const RIGHTDRAWER = 'RightDrawer'; const TOPDRAWER = 'TopDrawer'; const BOTTOMDRAWER = 'BottomDrawer'; const MAINCONTENT = 'MainContent'; /** * This is the SideDrawer component. It separates your mobile app's screen * into a main part and a menu part whereby the menu part is shown upon a swipe * gesture using a transition effect. */ class DrawerComponent { elementRef; viewContainer; drawer; mainTemplate; drawerTemplate; _gestureEnabled; constructor(elementRef, viewContainer) { this.elementRef = elementRef; this.viewContainer = viewContainer; this.drawer = this.elementRef.nativeElement; } get nativeElement() { return this.drawer; } set gestureEnabled(value) { this._gestureEnabled = value; this.updateGestureEnabled(); } updateGestureEnabled() { this.drawer.gestureEnabled = this._gestureEnabled; } static ɵfac = function DrawerComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DrawerComponent)(i0.ɵɵdirectiveInject(ElementRef), i0.ɵɵdirectiveInject(ViewContainerRef)); }; static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DrawerComponent, selectors: [["Drawer"]], ngContentSelectors: _c0, decls: 1, vars: 0, template: function DrawerComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵprojection(0); } }, encapsulation: 2 }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DrawerComponent, [{ type: Component, args: [{ selector: 'Drawer', template: '<ng-content></ng-content>' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }, { type: i0.ViewContainerRef, decorators: [{ type: Inject, args: [ViewContainerRef] }] }], null); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DrawerComponent, { className: "DrawerComponent", filePath: "module.ts", lineNumber: 26 }); })(); /** * Directive identifying the left drawer */ class LeftDrawerDirective { _elementRef; constructor(_elementRef) { this._elementRef = _elementRef; this._elementRef.nativeElement.id = LEFTDRAWER; } static ɵfac = function LeftDrawerDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LeftDrawerDirective)(i0.ɵɵdirectiveInject(ElementRef)); }; static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: LeftDrawerDirective, selectors: [["", "leftDrawer", ""]] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LeftDrawerDirective, [{ type: Directive, args: [{ selector: '[leftDrawer]' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }], null); })(); /** * Directive identifying the right drawer */ class RightDrawerDirective { _elementRef; constructor(_elementRef) { this._elementRef = _elementRef; this._elementRef.nativeElement.id = RIGHTDRAWER; } static ɵfac = function RightDrawerDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || RightDrawerDirective)(i0.ɵɵdirectiveInject(ElementRef)); }; static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: RightDrawerDirective, selectors: [["", "rightDrawer", ""]] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RightDrawerDirective, [{ type: Directive, args: [{ selector: '[rightDrawer]' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }], null); })(); /** * Directive identifying the right drawer */ class TopDrawerDirective { _elementRef; constructor(_elementRef) { this._elementRef = _elementRef; this._elementRef.nativeElement.id = TOPDRAWER; } static ɵfac = function TopDrawerDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TopDrawerDirective)(i0.ɵɵdirectiveInject(ElementRef)); }; static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TopDrawerDirective, selectors: [["", "topDrawer", ""]] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TopDrawerDirective, [{ type: Directive, args: [{ selector: '[topDrawer]' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }], null); })(); /** * Directive identifying the right drawer */ class BottomDrawerDirective { _elementRef; constructor(_elementRef) { this._elementRef = _elementRef; this._elementRef.nativeElement.id = BOTTOMDRAWER; } static ɵfac = function BottomDrawerDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BottomDrawerDirective)(i0.ɵɵdirectiveInject(ElementRef)); }; static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: BottomDrawerDirective, selectors: [["", "bottomDrawer", ""]] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BottomDrawerDirective, [{ type: Directive, args: [{ selector: '[bottomDrawer]' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }], null); })(); /** * Directive identifying the main content. */ class MainContentDirective { _elementRef; constructor(_elementRef) { this._elementRef = _elementRef; this._elementRef.nativeElement.id = MAINCONTENT; } static ɵfac = function MainContentDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainContentDirective)(i0.ɵɵdirectiveInject(ElementRef)); }; static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: MainContentDirective, selectors: [["", "mainContent", ""]] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MainContentDirective, [{ type: Directive, args: [{ selector: '[mainContent]' }] }], () => [{ type: i0.ElementRef, decorators: [{ type: Inject, args: [ElementRef] }] }], null); })(); const sideDrawerMeta = { insertChild: (parent, child) => { const drawer = parent; const childView = child; if (childView.id === MAINCONTENT) { drawer.mainContent = childView; } if (childView.id === LEFTDRAWER) { drawer.leftDrawer = childView; } if (childView.id === RIGHTDRAWER) { drawer.rightDrawer = childView; } if (childView.id === TOPDRAWER) { drawer.topDrawer = childView; } if (childView.id === BOTTOMDRAWER) { drawer.bottomDrawer = childView; } }, removeChild: (parent, child) => { const drawer = parent; const childView = child; if (childView.id === MAINCONTENT) { drawer.mainContent = null; } if (childView.id === LEFTDRAWER) { drawer.leftDrawer = null; } if (childView.id === RIGHTDRAWER) { drawer.rightDrawer = null; } if (childView.id === TOPDRAWER) { drawer.topDrawer = null; } if (childView.id === BOTTOMDRAWER) { drawer.bottomDrawer = null; } } }; /** * Directives identifying the Drawer. */ const SIDEDRAWER_DIRECTIVES = [LeftDrawerDirective, RightDrawerDirective, TopDrawerDirective, BottomDrawerDirective, MainContentDirective]; registerElement('Drawer', () => Drawer, sideDrawerMeta); /** * NgModule containing all of the RadSideDrawer directives. */ class DrawerModule { static ɵfac = function DrawerModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DrawerModule)(); }; static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DrawerModule }); static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DrawerModule, [{ type: NgModule, args: [{ declarations: [DrawerComponent, SIDEDRAWER_DIRECTIVES], exports: [DrawerComponent, SIDEDRAWER_DIRECTIVES] }] }], null, null); })(); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DrawerModule, { declarations: [DrawerComponent, LeftDrawerDirective, RightDrawerDirective, TopDrawerDirective, BottomDrawerDirective, MainContentDirective], exports: [DrawerComponent, LeftDrawerDirective, RightDrawerDirective, TopDrawerDirective, BottomDrawerDirective, MainContentDirective] }); })(); /** * Generated bundle index. Do not edit. */ export { BottomDrawerDirective, DrawerComponent, DrawerModule, LeftDrawerDirective, MainContentDirective, RightDrawerDirective, SIDEDRAWER_DIRECTIVES, TopDrawerDirective }; //# sourceMappingURL=nativescript-community-ui-drawer-angular.mjs.map