blob: 94c5bdeae0224837248b428f2eeadbfde6a27e1e [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/material/icon"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@covalent/core/breadcrumbs",["exports","@angular/core","@angular/common","@angular/material/icon","rxjs","rxjs/operators"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).covalent=e.covalent||{},e.covalent.core=e.covalent.core||{},e.covalent.core.breadcrumbs={}),e.ng.core,e.ng.common,e.ng.material.icon,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,r,o,i){"use strict";var a=function(){function e(e,t){this._elementRef=e,this._changeDetectorRef=t,this._displayCrumb=!0,this._width=0,this._displayIcon=!0,this._separatorIcon="chevron_right"}return Object.defineProperty(e.prototype,"separatorIcon",{get:function(){return this._separatorIcon},set:function(e){var t=this;this._separatorIcon=e,setTimeout((function(){t._changeDetectorRef.markForCheck()}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayIcon",{get:function(){return this._displayIcon},set:function(e){var t=this;this._displayIcon=e,setTimeout((function(){t._changeDetectorRef.markForCheck()}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayCrumb",{get:function(){return this._displayCrumb},set:function(e){var t=this;this._displayCrumb=e,setTimeout((function(){t._changeDetectorRef.markForCheck()}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayBinding",{get:function(){return this._displayCrumb?void 0:"none"},enumerable:!1,configurable:!0}),e.prototype.ngAfterViewInit=function(){var e=this;setTimeout((function(){e._width=e._elementRef.nativeElement.getBoundingClientRect().width,e._changeDetectorRef.markForCheck()}))},e.prototype._handleIconClick=function(e){e.stopPropagation(),e.preventDefault()},e}();a.decorators=[{type:t.Component,args:[{selector:"td-breadcrumb, a[td-breadcrumb]",template:'<ng-content></ng-content>\n<mat-icon\n *ngIf="displayIcon"\n class="td-breadcrumb-separator-icon"\n [style.cursor]="\'default\'"\n (click)="_handleIconClick($event)"\n>\n {{ separatorIcon }}\n</mat-icon>\n',host:{class:"mat-button td-breadcrumb"},changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[":host.td-breadcrumb{-ms-flex-align:center;-ms-flex-direction:row;-ms-flex-line-pack:center;-ms-flex-pack:end;align-content:center;align-items:center;box-sizing:border-box;display:inline-block;flex-direction:row;justify-content:flex-end;max-width:100%}:host.td-breadcrumb ::ng-deep>*{margin:0 10px}:host .td-breadcrumb-separator-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle}:host.mat-button{min-width:0;padding:0}"]}]}],a.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ChangeDetectorRef}]},a.propDecorators={displayBinding:[{type:t.HostBinding,args:["style.display"]}]};var c=function(){function e(e,t){this._elementRef=e,this._changeDetectorRef=t,this._resizeSubscription=o.Subscription.EMPTY,this._widthSubject=new o.Subject,this._resizing=!1,this._separatorIcon="chevron_right",this.hiddenBreadcrumbs=[]}return Object.defineProperty(e.prototype,"separatorIcon",{get:function(){return this._separatorIcon},set:function(e){this._separatorIcon=e,this.setCrumbIcons()},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this._resizeSubscription=o.merge(o.fromEvent(window,"resize").pipe(i.debounceTime(10)),this._widthSubject.asObservable().pipe(i.distinctUntilChanged())).subscribe((function(){e._resizing||(e._resizing=!0,setTimeout((function(){e._calculateVisibility(),e._resizing=!1,e._changeDetectorRef.markForCheck()}),100))}))},e.prototype.ngDoCheck=function(){this._elementRef&&this._elementRef.nativeElement&&this._widthSubject.next(this.nativeElementWidth)},e.prototype.ngAfterContentInit=function(){var e=this;this._contentChildrenSub=this._breadcrumbs.changes.pipe(i.startWith(this._breadcrumbs)).subscribe((function(){e.setCrumbIcons(),e._changeDetectorRef.markForCheck()}))},e.prototype.ngOnDestroy=function(){this._resizeSubscription.unsubscribe(),this._contentChildrenSub.unsubscribe()},Object.defineProperty(e.prototype,"nativeElementWidth",{get:function(){var e=this._elementRef.nativeElement,t=window.getComputedStyle(e),n=parseInt(t.borderLeft,10),r=parseInt(t.borderRight,10),o=parseInt(t.marginLeft,10),i=parseInt(t.marginRight,10),a=parseInt(t.paddingLeft,10),c=parseInt(t.paddingRight,10);return e.getBoundingClientRect().width-n-r-o-i-a-c},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._breadcrumbs?this._breadcrumbs.length:0},enumerable:!1,configurable:!0}),e.prototype.setCrumbIcons=function(){var e=this;if(this._breadcrumbs){var t=this._breadcrumbs.toArray();t.forEach((function(n,r){n.separatorIcon=e.separatorIcon,n.displayIcon=r<t.length-1}))}},e.prototype._calculateVisibility=function(){for(var e=this._breadcrumbs.toArray(),t=0,n=[],r=e.length-1;r>=0;r--){var o=e[r];t+o.width>this.nativeElementWidth?(o.displayCrumb=!1,n.push(o)):o.displayCrumb=!0,t+=o.width}this.hiddenBreadcrumbs=n,this._changeDetectorRef.markForCheck()},e}();c.decorators=[{type:t.Component,args:[{selector:"td-breadcrumbs",template:"<ng-content></ng-content>\n",host:{class:"td-breadcrumbs"},changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[":host{display:block;width:100%}:host.td-breadcrumbs{white-space:nowrap}"]}]}],c.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ChangeDetectorRef}]},c.propDecorators={_breadcrumbs:[{type:t.ContentChildren,args:[a,{descendants:!0}]}],separatorIcon:[{type:t.Input}]};var s=function(){};s.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,r.MatIconModule],declarations:[c,a],exports:[c,a]}]}],e.CovalentBreadcrumbsModule=s,e.TdBreadcrumbComponent=a,e.TdBreadcrumbsComponent=c,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=covalent-core-breadcrumbs.umd.min.js.map