| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@angular/cdk/portal"),require("@angular/material/tabs"),require("@angular/cdk/coercion"),require("@covalent/core/common"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@covalent/core/tab-select",["exports","@angular/core","@angular/common","@angular/forms","@angular/cdk/portal","@angular/material/tabs","@angular/cdk/coercion","@covalent/core/common","rxjs","rxjs/operators"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).covalent=e.covalent||{},e.covalent.core=e.covalent.core||{},e.covalent.core["tab-select"]={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.cdk.portal,e.ng.material.tabs,e.ng.cdk.coercion,e.covalent.core.common,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,o,r,a,i,s,c,l){"use strict"; |
| ***************************************************************************** */var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function p(e,t){function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;Object.create;var d=function(e,t){this._viewContainerRef=e,this._changeDetectorRef=t};var b=s.mixinDisabled(d),g=function(e){function t(t,n){return e.call(this,t,n)||this}return p(t,e),Object.defineProperty(t.prototype,"content",{get:function(){return this._contentPortal},enumerable:!1,configurable:!0}),t.prototype.ngOnInit=function(){this._contentPortal=new r.TemplatePortal(this._content,this._viewContainerRef)},t}(b);g.decorators=[{type:t.Component,args:[{selector:"td-tab-option",template:"<ng-template>\n <ng-content></ng-content>\n</ng-template>\n",changeDetection:t.ChangeDetectionStrategy.OnPush,inputs:["disabled"],styles:[""]}]}],g.ctorParameters=function(){return[{type:t.ViewContainerRef},{type:t.ChangeDetectorRef}]},g.propDecorators={_content:[{type:t.ViewChild,args:[t.TemplateRef,{static:!0}]}],value:[{type:t.Input}]};var h=function(e){this._changeDetectorRef=e};var f=s.mixinControlValueAccessor(s.mixinDisabled(s.mixinDisableRipple(h))),m=function(e){function n(n,o,r){var a=e.call(this,n)||this;return a._ngZone=o,a._elementRef=r,a._destroy=new c.Subject,a._widthSubject=new c.Subject,a._values=[],a._selectedIndex=0,a._stretchTabs=!1,a.valueChange=new t.EventEmitter,a}return p(n,e),Object.defineProperty(n.prototype,"selectedIndex",{get:function(){return this._selectedIndex},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"tabOptions",{get:function(){return this._tabOptions?this._tabOptions.toArray():void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"stretchTabs",{get:function(){return this._stretchTabs},set:function(e){this._stretchTabs=i.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),n.prototype.ngOnInit=function(){var e=this;this._ngZone.runOutsideAngular((function(){e._widthSubject.asObservable().pipe(l.takeUntil(e._destroy),l.distinctUntilChanged(),l.debounceTime(100)).subscribe((function(){e._ngZone.run((function(){e._matTabGroup.realignInkBar(),e._changeDetectorRef.markForCheck()}))})),c.timer(500,250).pipe(l.takeUntil(e._destroy)).subscribe((function(){e._elementRef&&e._elementRef.nativeElement&&e._widthSubject.next(e._elementRef.nativeElement.getBoundingClientRect().width)}))})),this.valueChanges.pipe(l.takeUntil(this._destroy)).subscribe((function(t){e._setValue(t)}))},n.prototype.ngAfterContentInit=function(){var e=this;this._refreshValues(),this._tabOptions.changes.pipe(l.takeUntil(this._destroy)).subscribe((function(){e._refreshValues()})),Promise.resolve().then((function(){e._setValue(e.value)}))},n.prototype.ngOnDestroy=function(){this._destroy.next(!0),this._destroy.unsubscribe()},n.prototype.selectedIndexChange=function(e){this._selectedIndex=e;var t=this._values[e];this.value=t,this.valueChange.emit(t),this.onChange(t)},n.prototype._refreshValues=function(){this._values=this.tabOptions.map((function(e){return e.value})),this._changeDetectorRef.markForCheck()},n.prototype._setValue=function(e){var t=this._values.indexOf(e);t>-1?this._selectedIndex=t:(this.value=this._values.length?this._values[0]:void 0,this._selectedIndex=0),this._changeDetectorRef.markForCheck()},n}(f);m.decorators=[{type:t.Component,args:[{changeDetection:t.ChangeDetectionStrategy.OnPush,providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return m})),multi:!0}],selector:"td-tab-select",template:'<mat-tab-group\n [attr.mat-stretch-tabs]="stretchTabs ? true : undefined"\n [backgroundColor]="backgroundColor"\n [color]="color"\n [disableRipple]="disableRipple"\n [selectedIndex]="selectedIndex"\n (selectedIndexChange)="selectedIndexChange($event)"\n>\n <ng-template let-tabOption ngFor [ngForOf]="tabOptions">\n <mat-tab [disabled]="tabOption.disabled || disabled">\n <ng-template matTabLabel>\n <ng-template *ngIf="tabOption.content" [cdkPortalOutlet]="tabOption.content"></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}"]}]}],m.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:t.NgZone},{type:t.ElementRef}]},m.propDecorators={_matTabGroup:[{type:t.ViewChild,args:[a.MatTabGroup,{static:!0}]}],_tabOptions:[{type:t.ContentChildren,args:[g,{descendants:!0}]}],stretchTabs:[{type:t.Input,args:["stretchTabs"]}],color:[{type:t.Input}],backgroundColor:[{type:t.Input}],valueChange:[{type:t.Output}]};var _=function(){};_.decorators=[{type:t.NgModule,args:[{declarations:[m,g],imports:[n.CommonModule,o.FormsModule,r.PortalModule,a.MatTabsModule],exports:[m,g]}]}],e.CovalentTabSelectModule=_,e.TdTabOptionBase=d,e.TdTabOptionComponent=g,e.TdTabSelectBase=h,e.TdTabSelectComponent=m,e._TdTabOptionMixinBase=b,e._TdTabSelectMixinBase=f,Object.defineProperty(e,"__esModule",{value:!0})})); |