UNPKG

8.06 kBSource Map (JSON)View Raw
1{"version":3,"file":"tabset.component.js","sourceRoot":"","sources":["../../src/tabs/tabset.component.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAa,MAAM,eAAe;OAGjE,EAAE,YAAY,EAAE,MAAM,iBAAiB;AAC9C,gCAAgC;AAChC,+EAA+E;AAE/E;IAyCE,yBAAmB,MAAoB;QAV/B,UAAK,GAAW,IAAI,CAAC;QAEtB,SAAI,GAAkB,EAAE,CAAC;QACzB,aAAQ,GAAO,EAAE,CAAC;QAQvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IAxCD,sBAAW,qCAAQ;QAFnB,6CAA6C;aAE7C;YACE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;aACD,UAAoB,KAAa;YAC/B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;;;OAJA;IAQD,sBAAW,sCAAS;QAFpB,kEAAkE;aAElE;YACE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;aACD,UAAqB,KAAa;YAChC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;;;OAJA;IAQD,sBAAW,iCAAI;QAFf,kDAAkD;aAElD;YACE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAgB,KAAY;YAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;;;OAJA;IAoBM,qCAAW,GAAlB;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAEM,gCAAM,GAAb,UAAc,GAAgB;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,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AiBT;iBACF,EAAG,EAAE;KACL,CAAC;IACF,kBAAkB;IACX,8BAAc,GAAmE,cAAM,OAAA;QAC9F,EAAC,IAAI,EAAE,YAAY,GAAG;KACrB,EAF6F,CAE7F,CAAC;IACK,8BAAc,GAA2C;QAChE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC9B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,qBAAqB,EAAG,EAAE,EAAE;KACjE,CAAC;IACF,sBAAC;AAAD,CAAC,AA9ID,IA8IC","sourcesContent":["import { Component, HostBinding, Input, OnDestroy } from '@angular/core';\n\nimport { TabDirective } from './tab.directive';\nimport { TabsetConfig } from './tabset.config';\n// todo: add active event to tab\n// todo: fix? mixing static and dynamic tabs position tabs in order of creation\n\nexport class TabsetComponent implements OnDestroy {\n /** if true tabs will be placed vertically */\n \n public get vertical():boolean {\n return this._vertical;\n }\n public set vertical(value:boolean) {\n this._vertical = value;\n this.setClassMap();\n }\n\n /** if true tabs fill the container and have a consistent width */\n \n public get justified():boolean {\n return this._justified;\n }\n public set justified(value:boolean) {\n this._justified = value;\n this.setClassMap();\n }\n\n /** navigation context class: 'tabs' or 'pills' */\n \n public get type():string {\n return this._type;\n }\n public set type(value:string) {\n this._type = value;\n this.setClassMap();\n }\n\n public clazz:boolean = true;\n\n public tabs:TabDirective[] = [];\n public classMap:any = {};\n\n protected isDestroyed:boolean;\n protected _vertical:boolean;\n protected _justified:boolean;\n protected _type:string;\n\n public constructor(config: TabsetConfig) {\n Object.assign(this, config);\n }\n\n public ngOnDestroy():void {\n this.isDestroyed = true;\n }\n\n public addTab(tab:TabDirective):void {\n this.tabs.push(tab);\n tab.active = this.tabs.length === 1 && tab.active !== false;\n }\n\n public removeTab(tab:TabDirective):void {\n let index = this.tabs.indexOf(tab);\n if (index === -1 || this.isDestroyed) {\n return;\n }\n // Select a new tab if the tab to be removed is selected and not destroyed\n if (tab.active && this.hasAvailableTabs(index)) {\n let newActiveIndex = this.getClosestTabIndex(index);\n this.tabs[newActiveIndex].active = true;\n }\n\n tab.removed.emit(tab);\n this.tabs.splice(index, 1);\n }\n\n protected getClosestTabIndex(index:number):number {\n let tabsLength = this.tabs.length;\n if (!tabsLength) {\n return -1;\n }\n\n for (let step = 1; step <= tabsLength; step += 1) {\n let prevIndex = index - step;\n let nextIndex = index + step;\n if (this.tabs[prevIndex] && !this.tabs[prevIndex].disabled) {\n return prevIndex;\n }\n if (this.tabs[nextIndex] && !this.tabs[nextIndex].disabled) {\n return nextIndex;\n }\n }\n return -1;\n }\n\n protected hasAvailableTabs(index:number):boolean {\n let tabsLength = this.tabs.length;\n if (!tabsLength) {\n return false;\n }\n\n for (let i = 0; i < tabsLength; i += 1) {\n if (!this.tabs[i].disabled && i !== index) {\n return true;\n }\n }\n return false;\n }\n\n protected setClassMap():void {\n this.classMap = {\n 'nav-stacked': this.vertical,\n 'nav-justified': this.justified,\n [`nav-${this.type}`]: true\n };\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Component, args: [{\n selector: 'tabset',\n template: `\n <ul class=\"nav\" [ngClass]=\"classMap\" (click)=\"$event.preventDefault()\">\n <li *ngFor=\"let tabz of tabs\" [ngClass]=\"['nav-item', tabz.customClass || '']\"\n [class.active]=\"tabz.active\" [class.disabled]=\"tabz.disabled\">\n <a href=\"javascript:void(0);\" class=\"nav-link\"\n [class.active]=\"tabz.active\" [class.disabled]=\"tabz.disabled\"\n (click)=\"tabz.active = true\">\n <span [ngTransclude]=\"tabz.headingRef\">{{tabz.heading}}</span>\n <span *ngIf=\"tabz.removable\">\n <span (click)=\"$event.preventDefault(); removeTab(tabz);\" class=\"glyphicon glyphicon-remove-circle\"></span>\n </span>\n </a>\n </li>\n </ul>\n <div class=\"tab-content\">\n <ng-content></ng-content>\n </div>\n `\n}, ] },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: TabsetConfig, },\n];\nstatic propDecorators: {[key: string]: DecoratorInvocation[]} = {\n'vertical': [{ type: Input },],\n'justified': [{ type: Input },],\n'type': [{ type: Input },],\n'clazz': [{ type: HostBinding, args: ['class.tab-container', ] },],\n};\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file