@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 10.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@lxlib/seed/reuse-tab"),require("@lxlib/theme"),require("@lxlib/util"),require("ng-zorro-antd/affix"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/observers"),require("@angular/common"),require("ng-zorro-antd/breadcrumb"),require("ng-zorro-antd/skeleton")):"function"==typeof define&&define.amd?define("@lxlib/seed/page-header",["exports","@angular/core","@angular/router","@lxlib/seed/reuse-tab","@lxlib/theme","@lxlib/util","ng-zorro-antd/affix","rxjs","rxjs/operators","@angular/cdk/observers","@angular/common","ng-zorro-antd/breadcrumb","ng-zorro-antd/skeleton"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed["page-header"]={}),e.ng.core,e.ng.router,e.lxlib.seed["reuse-tab"],e.lxlib.theme,e.lxlib.util,e["ng-zorro-antd/affix"],e.rxjs,e.rxjs.operators,e.ng.cdk.observers,e.ng.common,e["ng-zorro-antd/breadcrumb"],e["ng-zorro-antd/skeleton"])}(this,(function(e,t,n,i,r,o,a,l,s,p,u,c,d){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var h=function(){return(h=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function f(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function g(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function m(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}var y=function(){function e(){this.home="首页",this.homeLink="/",this.autoBreadcrumb=!0,this.recursiveBreadcrumb=!1,this.autoTitle=!0,this.syncTitle=!1,this.fixed=!1,this.fixedOffsetTop=64}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var v=function(){function e(e,t,i,r,o,a,p,u,c){var d=this;this.renderer=i,this.router=r,this.menuSrv=o,this.i18nSrv=a,this.titleSrv=p,this.reuseSrv=u,this.cdr=c,this.inited=!1,this.unsubscribe$=new l.Subject,this._titleVal="",this.paths=[],this.loading=!1,this.wide=!1,Object.assign(this,h(h({},new y),e)),t.notify.pipe(s.takeUntil(this.unsubscribe$),s.filter((function(e){return d.affix&&"layout"===e.type&&"collapsed"===e.name}))).subscribe((function(){return d.affix.updatePosition({})})),l.merge(o.change.pipe(s.filter((function(){return d.inited}))),r.events.pipe(s.filter((function(e){return e instanceof n.NavigationEnd}))),a.change).pipe(s.takeUntil(this.unsubscribe$)).subscribe((function(){d._menus=null,d.refresh()}))}return Object.defineProperty(e.prototype,"menus",{get:function(){return this._menus||(this._menus=this.menuSrv.getPathByUrl(this.router.url.split("?")[0],this.recursiveBreadcrumb)),this._menus},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){e instanceof t.TemplateRef?(this._title=null,this._titleTpl=e,this._titleVal=""):(this._title=e,this._titleVal=this._title)},enumerable:!0,configurable:!0}),e.prototype.refresh=function(){this.setTitle().genBreadcrumb(),this.cdr.detectChanges()},e.prototype.genBreadcrumb=function(){var e=this;if(!(this.breadcrumb||!this.autoBreadcrumb||this.menus.length<=0)){var t=[];return this.menus.forEach((function(n){if(void 0===n.hideInBreadcrumb||!n.hideInBreadcrumb){var i=n.text;n.i18n&&e.i18nSrv&&(i=e.i18nSrv.fanyi(n.i18n)),t.push({title:i,link:n.link&&[n.link]})}})),this.home&&t.splice(0,0,{title:this.homeI18n&&this.i18nSrv&&this.i18nSrv.fanyi(this.homeI18n)||this.home,link:[this.homeLink]}),this.paths=t,this}this.paths=[]},e.prototype.setTitle=function(){if(null==this._title&&null==this._titleTpl&&this.autoTitle&&this.menus.length>0){var e=this.menus[this.menus.length-1],t=e.text;e.i18n&&this.i18nSrv&&(t=this.i18nSrv.fanyi(e.i18n)),this._titleVal=t}return this._titleVal&&this.syncTitle&&(this.titleSrv&&this.titleSrv.setTitle(this._titleVal),this.reuseSrv&&(this.reuseSrv.title=this._titleVal)),this},e.prototype.checkContent=function(){o.isEmpty(this.conTpl.nativeElement)?this.renderer.setAttribute(this.conTpl.nativeElement,"hidden",""):this.renderer.removeAttribute(this.conTpl.nativeElement,"hidden")},e.prototype.ngOnInit=function(){this.refresh(),this.inited=!0},e.prototype.ngAfterViewInit=function(){this.checkContent()},e.prototype.ngOnChanges=function(){this.inited&&this.refresh()},e.prototype.ngOnDestroy=function(){var e=this.unsubscribe$;e.next(),e.complete()},e.decorators=[{type:t.Component,args:[{selector:"page-header",exportAs:"pageHeader",template:'<nz-affix #affix *ngIf="fixed;else phTpl" [nzOffsetTop]="fixedOffsetTop">\n <ng-template [ngTemplateOutlet]="phTpl"></ng-template>\n</nz-affix>\n<ng-template #phTpl>\n <div class="page-header">\n <div [ngClass]="{\'page-header__wide\': wide}">\n <nz-skeleton [nzLoading]="loading"\n [nzTitle]="false"\n [nzActive]="true"\n [nzParagraph]="{rows: 3}"\n [nzAvatar]="{ size: \'large\', shape: \'circle\' }">\n <ng-container *ngIf="!breadcrumb; else breadcrumb">\n <nz-breadcrumb *ngIf="paths && paths.length > 0">\n <nz-breadcrumb-item *ngFor="let i of paths">\n <ng-container *ngIf="i.link">\n <a [routerLink]="i.link">{{i.title}}</a>\n </ng-container>\n <ng-container *ngIf="!i.link">{{i.title}}</ng-container>\n </nz-breadcrumb-item>\n </nz-breadcrumb>\n </ng-container>\n <div class="page-header__detail">\n <div *ngIf="logo" class="page-header__logo">\n <ng-template [ngTemplateOutlet]="logo"></ng-template>\n </div>\n <div class="page-header__main">\n <div class="page-header__row">\n <h1 *ngIf="_titleVal || _titleTpl" class="page-header__title">\n <ng-container *ngIf="_titleVal; else _titleTpl">{{_titleVal}}</ng-container>\n </h1>\n <div *ngIf="action" class="page-header__action">\n <ng-template [ngTemplateOutlet]="action"></ng-template>\n </div>\n </div>\n <div class="page-header__row">\n <div class="page-header__desc" (cdkObserveContent)="checkContent()" #conTpl>\n <ng-content></ng-content>\n <ng-template [ngTemplateOutlet]="content"></ng-template>\n </div>\n <div *ngIf="extra" class="page-header__extra">\n <ng-template [ngTemplateOutlet]="extra"></ng-template>\n </div>\n </div>\n </div>\n </div>\n <ng-template [ngTemplateOutlet]="tab"></ng-template>\n </nz-skeleton>\n </div>\n </div>\n</ng-template>\n',preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None}]}],e.ctorParameters=function(){return[{type:y},{type:r.SettingsService},{type:t.Renderer2},{type:n.Router},{type:r.MenuService},{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[r.LXLIB_I18N_TOKEN]}]},{type:r.TitleService,decorators:[{type:t.Optional},{type:t.Inject,args:[r.TitleService]}]},{type:i.ReuseTabService,decorators:[{type:t.Optional},{type:t.Inject,args:[i.ReuseTabService]}]},{type:t.ChangeDetectorRef}]},e.propDecorators={conTpl:[{type:t.ViewChild,args:["conTpl",{static:!1}]}],affix:[{type:t.ViewChild,args:["affix",{static:!1}]}],title:[{type:t.Input}],loading:[{type:t.Input}],wide:[{type:t.Input}],home:[{type:t.Input}],homeLink:[{type:t.Input}],homeI18n:[{type:t.Input}],autoBreadcrumb:[{type:t.Input}],autoTitle:[{type:t.Input}],syncTitle:[{type:t.Input}],fixed:[{type:t.Input}],fixedOffsetTop:[{type:t.Input}],breadcrumb:[{type:t.Input}],recursiveBreadcrumb:[{type:t.Input}],logo:[{type:t.Input}],action:[{type:t.Input}],content:[{type:t.Input}],extra:[{type:t.Input}],tab:[{type:t.Input}]},f([o.InputBoolean(),g("design:type",Object)],e.prototype,"loading",void 0),f([o.InputBoolean(),g("design:type",Object)],e.prototype,"wide",void 0),f([o.InputBoolean(),g("design:type",Boolean)],e.prototype,"autoBreadcrumb",void 0),f([o.InputBoolean(),g("design:type",Boolean)],e.prototype,"autoTitle",void 0),f([o.InputBoolean(),g("design:type",Boolean)],e.prototype,"syncTitle",void 0),f([o.InputBoolean(),g("design:type",Boolean)],e.prototype,"fixed",void 0),f([o.InputNumber(),g("design:type",Number)],e.prototype,"fixedOffsetTop",void 0),f([o.InputBoolean(),g("design:type",Boolean)],e.prototype,"recursiveBreadcrumb",void 0),e}();var x=[v],I=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[u.CommonModule,n.RouterModule,p.ObserversModule,o.LxlibUtilModule,a.NzAffixModule,d.NzSkeletonModule,c.NzBreadCrumbModule],declarations:b(x),exports:b(x)}]}],e}();e.PageHeaderComponent=v,e.PageHeaderConfig=y,e.PageHeaderModule=I,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=pageHeader.umd.min.js.map