UNPKG

ngx-tabset

Version:

A very simple library to let you create some tabs

165 lines (157 loc) 5.89 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common'], factory) : (factory((global.ng = global.ng || {}, global.ng.ngxTabset = {}),global.ng.core,global.ng.common)); }(this, (function (exports,core,common) { 'use strict'; /** * @license ngx-tabset * MIT license */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var TabComponent = (function () { function TabComponent() { this.active = false; this.disabled = false; this.bypassDOM = false; this.customPaneClass = ''; } TabComponent.decorators = [ { type: core.Component, args: [{ selector: 'ngx-tab', template: "\n <div *ngIf=\"active\"\n class=\"pane\"\n [ngClass]=\"customPaneClass\">\n <div *ngIf=\"bypassDOM\">\n <ng-container [ngTemplateOutlet]=\"template\"></ng-container>\n </div>\n <div *ngIf=\"!bypassDOM\">\n <ng-content></ng-content>\n </div>\n </div>\n " },] }, ]; /** @nocollapse */ TabComponent.ctorParameters = function () { return []; }; TabComponent.propDecorators = { "tabTitle": [{ type: core.Input },], "tabSubTitle": [{ type: core.Input },], "active": [{ type: core.Input },], "disabled": [{ type: core.Input },], "bypassDOM": [{ type: core.Input },], "customPaneClass": [{ type: core.Input },], "template": [{ type: core.ContentChild, args: [core.TemplateRef,] },], }; return TabComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var TabsetComponent = (function () { function TabsetComponent() { this.disableStyle = false; this.customNavClass = ''; this.customTabsClass = ''; this.onSelect = new core.EventEmitter(); } /** * @return {?} */ TabsetComponent.prototype.ngAfterContentInit = /** * @return {?} */ function () { // get all active tabs var /** @type {?} */ activeTabs = this.tabs.filter(function (tab) { return tab.active; }); // if there is no active tab set, activate the first if (activeTabs.length === 0) { this.selectTab(this.tabs.first); } }; /** * @param {?} tabToSelect * @return {?} */ TabsetComponent.prototype.selectTab = /** * @param {?} tabToSelect * @return {?} */ function (tabToSelect) { if (tabToSelect.disabled === true || tabToSelect.active === true) { return; } // deactivate all tabs this.tabs.toArray().forEach(function (tab) { return tab.active = false; }); // activate the tab the user has clicked on. tabToSelect.active = true; this.onSelect.emit(this.tabs.toArray().indexOf(tabToSelect)); }; TabsetComponent.decorators = [ { type: core.Component, args: [{ selector: 'ngx-tabset', template: "\n <ul class=\"nav-tabset\"\n [class.disable-style]=\"disableStyle\"\n [ngClass]=\"customNavClass\">\n <li *ngFor=\"let tab of tabs\"\n (click)=\"selectTab(tab)\"\n class=\"nav-tab\"\n [class.active]=\"tab.active\"\n [class.disabled]=\"tab.disabled\">\n <span>{{ tab.tabTitle }}</span>\n <span *ngIf=\"!!tab.tabSubTitle\" class=\"tab-subtitle\">{{ tab.tabSubTitle }}</span>\n </li>\n </ul>\n <div class=\"tabs-container\"\n [ngClass]=\"customTabsClass\">\n <ng-content></ng-content>\n </div>\n " },] }, ]; /** @nocollapse */ TabsetComponent.ctorParameters = function () { return []; }; TabsetComponent.propDecorators = { "tabs": [{ type: core.ContentChildren, args: [TabComponent,] },], "disableStyle": [{ type: core.Input },], "customNavClass": [{ type: core.Input },], "customTabsClass": [{ type: core.Input },], "onSelect": [{ type: core.Output },], }; return TabsetComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var TabsModule = (function () { function TabsModule() { } /** * Use in AppModule: new instance of NgxTabset. * @return {?} */ TabsModule.forRoot = /** * Use in AppModule: new instance of NgxTabset. * @return {?} */ function () { return { ngModule: TabsModule, providers: [] }; }; /** * Use in features modules with lazy loading: new instance of NgxTabset. * @return {?} */ TabsModule.forChild = /** * Use in features modules with lazy loading: new instance of NgxTabset. * @return {?} */ function () { return { ngModule: TabsModule, providers: [] }; }; TabsModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ TabComponent, TabsetComponent, ], exports: [ TabComponent, TabsetComponent, ], imports: [common.CommonModule] },] }, ]; /** @nocollapse */ TabsModule.ctorParameters = function () { return []; }; return TabsModule; }()); exports.TabsetComponent = TabsetComponent; exports.TabComponent = TabComponent; exports.TabsModule = TabsModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ngx-tabset.umd.js.map