UNPKG

ngx-tabset

Version:

A very simple library to let you create some tabs

183 lines (173 loc) 5.86 kB
/** * @license ngx-tabset * MIT license */ import { Component, ContentChild, ContentChildren, EventEmitter, Input, NgModule, Output, TemplateRef } from '@angular/core'; import { CommonModule } from '@angular/common'; /** * @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: 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: Input },], "tabSubTitle": [{ type: Input },], "active": [{ type: Input },], "disabled": [{ type: Input },], "bypassDOM": [{ type: Input },], "customPaneClass": [{ type: Input },], "template": [{ type: ContentChild, args: [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 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: 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: ContentChildren, args: [TabComponent,] },], "disableStyle": [{ type: Input },], "customNavClass": [{ type: Input },], "customTabsClass": [{ type: Input },], "onSelect": [{ type: 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: NgModule, args: [{ declarations: [ TabComponent, TabsetComponent, ], exports: [ TabComponent, TabsetComponent, ], imports: [CommonModule] },] }, ]; /** @nocollapse */ TabsModule.ctorParameters = function () { return []; }; return TabsModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ // Public classes. /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * Entry point for all public APIs of the package. */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * Generated bundle index. Do not edit. */ export { TabsetComponent, TabComponent, TabsModule }; //# sourceMappingURL=ngx-tabset.js.map