blob: 49cca3bd8737287adcf57f82a70df0ad21a6c237 [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/material/tabs"),require("@angular/forms"),require("@angular/cdk/coercion"),require("@angular/core"),require("@angular/cdk/portal"),require("@covalent/core/common")):"function"==typeof define&&define.amd?define("@covalent/core/tab-select",["exports","@angular/common","@angular/material/tabs","@angular/forms","@angular/cdk/coercion","@angular/core","@angular/cdk/portal","@covalent/core/common"],t):t((e.covalent=e.covalent||{},e.covalent.core=e.covalent.core||{},e.covalent.core["tab-select"]={}),e.ng.common,e.ng.material.tabs,e.ng.forms,e.ng.cdk.coercion,e.ng.core,e.ng.cdk.portal,e.covalent.core.common)}(this,function(e,t,n,o,r,a,s,i){"use strict";var c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function l(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function u(e,t){this._viewContainerRef=e,this._changeDetectorRef=t}var p,d=i.mixinDisabled(u),h=(l(b,p=d),Object.defineProperty(b.prototype,"content",{get:function(){return this._contentPortal},enumerable:!0,configurable:!0}),b.prototype.ngOnInit=function(){this._contentPortal=new s.TemplatePortal(this._content,this._viewContainerRef)},b.decorators=[{type:a.Component,args:[{selector:"td-tab-option",template:"<ng-template>\n <ng-content></ng-content>\n</ng-template>\n",changeDetection:a.ChangeDetectionStrategy.OnPush,inputs:["disabled"],styles:[""]}]}],b.ctorParameters=function(){return[{type:a.ViewContainerRef},{type:a.ChangeDetectorRef}]},b.propDecorators={_content:[{type:a.ViewChild,args:[a.TemplateRef]}],value:[{type:a.Input,args:["value"]}]},b);function b(e,t){return p.call(this,e,t)||this}function g(e){this._changeDetectorRef=e}var f,m=i.mixinControlValueAccessor(i.mixinDisabled(i.mixinDisableRipple(g))),_=(l(y,f=m),Object.defineProperty(y.prototype,"selectedIndex",{get:function(){return this._selectedIndex},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"tabOptions",{get:function(){return this._tabOptions?this._tabOptions.toArray():undefined},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"stretchTabs",{get:function(){return this._stretchTabs},set:function(e){this._stretchTabs=r.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),y.prototype.ngOnInit=function(){var t=this;this._subs.push(this.valueChanges.subscribe(function(e){t._setValue(e)}))},y.prototype.ngAfterContentInit=function(){var e=this;this._refreshValues(),this._subs.push(this._tabOptions.changes.subscribe(function(){e._refreshValues()})),Promise.resolve().then(function(){e._setValue(e.value)})},y.prototype.ngOnDestroy=function(){this._subs&&this._subs.length&&this._subs.forEach(function(e){e.unsubscribe()})},y.prototype.selectedIndexChange=function(e){this._selectedIndex=e;var t=this._values[e];this.value=t,this.valueChange.emit(t),this.onChange(t)},y.prototype._refreshValues=function(){this._values=this.tabOptions.map(function(e){return e.value}),this._changeDetectorRef.markForCheck()},y.prototype._setValue=function(e){var t=this._values.indexOf(e);-1<t?this._selectedIndex=t:(this.value=this._values.length?this._values[0]:undefined,this._selectedIndex=0),this._changeDetectorRef.markForCheck()},y.decorators=[{type:a.Component,args:[{changeDetection:a.ChangeDetectionStrategy.OnPush,providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return y}),multi:!0}],selector:"td-tab-select",template:'<mat-tab-group [attr.mat-stretch-tabs]="stretchTabs ? true : undefined"\n [backgroundColor]="backgroundColor"\n [color]="color"\n [disableRipple]="disableRipple"\n [selectedIndex]="selectedIndex"\n (selectedIndexChange)="selectedIndexChange($event)">\n <ng-template let-tabOption\n ngFor\n [ngForOf]="tabOptions">\n <mat-tab [disabled]="tabOption.disabled || disabled">\n <ng-template matTabLabel>\n <ng-template *ngIf="tabOption.content" [cdkPortalOutlet]="tabOption.content">\n </ng-template>\n </ng-template>\n </mat-tab>\n </ng-template>\n</mat-tab-group>\n',inputs:["value","disabled","disableRipple"],styles:[":host::ng-deep>.mat-tab-group>.mat-tab-body-wrapper{display:none}"]}]}],y.ctorParameters=function(){return[{type:a.ChangeDetectorRef}]},y.propDecorators={_tabOptions:[{type:a.ContentChildren,args:[h]}],stretchTabs:[{type:a.Input,args:["stretchTabs"]}],color:[{type:a.Input,args:["color"]}],backgroundColor:[{type:a.Input,args:["backgroundColor"]}],valueChange:[{type:a.Output}]},y);function y(e){var t=f.call(this,e)||this;return t._subs=[],t._values=[],t._selectedIndex=0,t._stretchTabs=!1,t.valueChange=new a.EventEmitter,t}var v=(C.decorators=[{type:a.NgModule,args:[{declarations:[_,h],imports:[t.CommonModule,o.FormsModule,s.PortalModule,n.MatTabsModule],exports:[_,h]}]}],C);function C(){}e.CovalentTabSelectModule=v,e.TdTabSelectBase=g,e._TdTabSelectMixinBase=m,e.TdTabSelectComponent=_,e.TdTabOptionBase=u,e._TdTabOptionMixinBase=d,e.TdTabOptionComponent=h,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=covalent-core-tab-select.umd.min.js.map