UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

557 lines (550 loc) 19.8 kB
import { Injectable, ɵɵdefineInjectable, TemplateRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, Optional, Inject, ChangeDetectorRef, ViewChild, Input, NgModule } from '@angular/core'; import { __assign, __decorate, __metadata, __spread } from 'tslib'; import { NavigationEnd, Router, RouterModule } from '@angular/router'; import { ReuseTabService } from '@lxlib/seed/reuse-tab'; import { SettingsService, MenuService, LXLIB_I18N_TOKEN, TitleService } from '@lxlib/theme'; import { isEmpty, InputBoolean, InputNumber, LxlibUtilModule } from '@lxlib/util'; import { NzAffixModule } from 'ng-zorro-antd/affix'; import { Subject, merge } from 'rxjs'; import { takeUntil, filter } from 'rxjs/operators'; import { ObserversModule } from '@angular/cdk/observers'; import { CommonModule } from '@angular/common'; import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb'; import { NzSkeletonModule } from 'ng-zorro-antd/skeleton'; /** * @fileoverview added by tsickle * Generated from: page-header.config.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var PageHeaderConfig = /** @class */ (function () { function PageHeaderConfig() { /** * 首页文本,若指定空表示不显示 */ this.home = '首页'; /** * 首页链接 */ this.homeLink = '/'; /** * 自动生成导航,以当前路由从主菜单中定位 */ this.autoBreadcrumb = true; /** * 自动向上递归查找 * - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项 */ this.recursiveBreadcrumb = false; /** * 自动生成标题,以当前路由从主菜单中定位 */ this.autoTitle = true; /** * 是否自动将标准信息同步至 `TitleService`、`ReuseService` 下 */ this.syncTitle = false; /** * 是否固定模式 */ this.fixed = false; /** * 固定偏移值 */ this.fixedOffsetTop = 64; } PageHeaderConfig.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ PageHeaderConfig.ɵprov = ɵɵdefineInjectable({ factory: function PageHeaderConfig_Factory() { return new PageHeaderConfig(); }, token: PageHeaderConfig, providedIn: "root" }); return PageHeaderConfig; }()); if (false) { /** * 首页文本,若指定空表示不显示 * @type {?} */ PageHeaderConfig.prototype.home; /** * 首页链接 * @type {?} */ PageHeaderConfig.prototype.homeLink; /** * 首页链接国际化参数 * @type {?} */ PageHeaderConfig.prototype.homeI18n; /** * 自动生成导航,以当前路由从主菜单中定位 * @type {?} */ PageHeaderConfig.prototype.autoBreadcrumb; /** * 自动向上递归查找 * - 菜单数据源包含 `/ware`,则 `/ware/1` 也视为 `/ware` 项 * @type {?} */ PageHeaderConfig.prototype.recursiveBreadcrumb; /** * 自动生成标题,以当前路由从主菜单中定位 * @type {?} */ PageHeaderConfig.prototype.autoTitle; /** * 是否自动将标准信息同步至 `TitleService`、`ReuseService` 下 * @type {?} */ PageHeaderConfig.prototype.syncTitle; /** * 是否固定模式 * @type {?} */ PageHeaderConfig.prototype.fixed; /** * 固定偏移值 * @type {?} */ PageHeaderConfig.prototype.fixedOffsetTop; } /** * @fileoverview added by tsickle * Generated from: page-header.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function PageHeaderPath() { } if (false) { /** @type {?|undefined} */ PageHeaderPath.prototype.title; /** @type {?|undefined} */ PageHeaderPath.prototype.link; } var PageHeaderComponent = /** @class */ (function () { // #endregion function PageHeaderComponent(cog, settings, renderer, router, menuSrv, i18nSrv, titleSrv, reuseSrv, cdr) { var _this = this; this.renderer = renderer; this.router = router; this.menuSrv = menuSrv; this.i18nSrv = i18nSrv; this.titleSrv = titleSrv; this.reuseSrv = reuseSrv; this.cdr = cdr; this.inited = false; this.unsubscribe$ = new Subject(); this._titleVal = ''; this.paths = []; this.loading = false; this.wide = false; Object.assign(this, __assign(__assign({}, new PageHeaderConfig()), cog)); settings.notify .pipe(takeUntil(this.unsubscribe$), filter((/** * @param {?} w * @return {?} */ function (w) { return _this.affix && w.type === 'layout' && w.name === 'collapsed'; }))) .subscribe((/** * @return {?} */ function () { return _this.affix.updatePosition((/** @type {?} */ ({}))); })); merge(menuSrv.change.pipe(filter((/** * @return {?} */ function () { return _this.inited; }))), router.events.pipe(filter((/** * @param {?} e * @return {?} */ function (e) { return e instanceof NavigationEnd; }))), i18nSrv.change) .pipe(takeUntil(this.unsubscribe$)) .subscribe((/** * @return {?} */ function () { _this._menus = null; _this.refresh(); })); } Object.defineProperty(PageHeaderComponent.prototype, "menus", { get: /** * @private * @return {?} */ function () { if (this._menus) { return this._menus; } this._menus = this.menuSrv.getPathByUrl(this.router.url.split('?')[0], this.recursiveBreadcrumb); return this._menus; }, enumerable: true, configurable: true }); Object.defineProperty(PageHeaderComponent.prototype, "title", { set: /** * @param {?} value * @return {?} */ function (value) { if (value instanceof TemplateRef) { this._title = null; this._titleTpl = value; this._titleVal = ''; } else { this._title = value; this._titleVal = this._title; } }, enumerable: true, configurable: true }); /** * @return {?} */ PageHeaderComponent.prototype.refresh = /** * @return {?} */ function () { this.setTitle().genBreadcrumb(); this.cdr.detectChanges(); }; /** * @private * @return {?} */ PageHeaderComponent.prototype.genBreadcrumb = /** * @private * @return {?} */ function () { var _this = this; if (this.breadcrumb || !this.autoBreadcrumb || this.menus.length <= 0) { this.paths = []; return; } /** @type {?} */ var paths = []; this.menus.forEach((/** * @param {?} item * @return {?} */ function (item) { if (typeof item.hideInBreadcrumb !== 'undefined' && item.hideInBreadcrumb) return; /** @type {?} */ var title = item.text; if (item.i18n && _this.i18nSrv) title = _this.i18nSrv.fanyi(item.i18n); paths.push({ title: title, link: (/** @type {?} */ ((item.link && [item.link]))) }); })); // add home if (this.home) { paths.splice(0, 0, { title: (this.homeI18n && this.i18nSrv && this.i18nSrv.fanyi(this.homeI18n)) || this.home, link: [this.homeLink], }); } this.paths = paths; return this; }; /** * @private * @template THIS * @this {THIS} * @return {THIS} */ PageHeaderComponent.prototype.setTitle = /** * @private * @template THIS * @this {THIS} * @return {THIS} */ function () { if ((/** @type {?} */ (this))._title == null && (/** @type {?} */ (this))._titleTpl == null && (/** @type {?} */ (this)).autoTitle && (/** @type {?} */ (this)).menus.length > 0) { /** @type {?} */ var item = (/** @type {?} */ (this)).menus[(/** @type {?} */ (this)).menus.length - 1]; /** @type {?} */ var title = item.text; if (item.i18n && (/** @type {?} */ (this)).i18nSrv) title = (/** @type {?} */ (this)).i18nSrv.fanyi(item.i18n); (/** @type {?} */ (this))._titleVal = (/** @type {?} */ (title)); } if ((/** @type {?} */ (this))._titleVal && (/** @type {?} */ (this)).syncTitle) { if ((/** @type {?} */ (this)).titleSrv) { (/** @type {?} */ (this)).titleSrv.setTitle((/** @type {?} */ (this))._titleVal); } if ((/** @type {?} */ (this)).reuseSrv) { (/** @type {?} */ (this)).reuseSrv.title = (/** @type {?} */ (this))._titleVal; } } return (/** @type {?} */ (this)); }; /** * @return {?} */ PageHeaderComponent.prototype.checkContent = /** * @return {?} */ function () { if (isEmpty(this.conTpl.nativeElement)) { this.renderer.setAttribute(this.conTpl.nativeElement, 'hidden', ''); } else { this.renderer.removeAttribute(this.conTpl.nativeElement, 'hidden'); } }; /** * @return {?} */ PageHeaderComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.refresh(); this.inited = true; }; /** * @return {?} */ PageHeaderComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { this.checkContent(); }; /** * @return {?} */ PageHeaderComponent.prototype.ngOnChanges = /** * @return {?} */ function () { if (this.inited) this.refresh(); }; /** * @return {?} */ PageHeaderComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { var unsubscribe$ = this.unsubscribe$; unsubscribe$.next(); unsubscribe$.complete(); }; PageHeaderComponent.decorators = [ { type: 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: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ PageHeaderComponent.ctorParameters = function () { return [ { type: PageHeaderConfig }, { type: SettingsService }, { type: Renderer2 }, { type: Router }, { type: MenuService }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LXLIB_I18N_TOKEN,] }] }, { type: TitleService, decorators: [{ type: Optional }, { type: Inject, args: [TitleService,] }] }, { type: ReuseTabService, decorators: [{ type: Optional }, { type: Inject, args: [ReuseTabService,] }] }, { type: ChangeDetectorRef } ]; }; PageHeaderComponent.propDecorators = { conTpl: [{ type: ViewChild, args: ['conTpl', { static: false },] }], affix: [{ type: ViewChild, args: ['affix', { static: false },] }], title: [{ type: Input }], loading: [{ type: Input }], wide: [{ type: Input }], home: [{ type: Input }], homeLink: [{ type: Input }], homeI18n: [{ type: Input }], autoBreadcrumb: [{ type: Input }], autoTitle: [{ type: Input }], syncTitle: [{ type: Input }], fixed: [{ type: Input }], fixedOffsetTop: [{ type: Input }], breadcrumb: [{ type: Input }], recursiveBreadcrumb: [{ type: Input }], logo: [{ type: Input }], action: [{ type: Input }], content: [{ type: Input }], extra: [{ type: Input }], tab: [{ type: Input }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], PageHeaderComponent.prototype, "loading", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], PageHeaderComponent.prototype, "wide", void 0); __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], PageHeaderComponent.prototype, "autoBreadcrumb", void 0); __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], PageHeaderComponent.prototype, "autoTitle", void 0); __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], PageHeaderComponent.prototype, "syncTitle", void 0); __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], PageHeaderComponent.prototype, "fixed", void 0); __decorate([ InputNumber(), __metadata("design:type", Number) ], PageHeaderComponent.prototype, "fixedOffsetTop", void 0); __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], PageHeaderComponent.prototype, "recursiveBreadcrumb", void 0); return PageHeaderComponent; }()); if (false) { /** * @type {?} * @private */ PageHeaderComponent.prototype.inited; /** * @type {?} * @private */ PageHeaderComponent.prototype.unsubscribe$; /** * @type {?} * @private */ PageHeaderComponent.prototype.conTpl; /** * @type {?} * @private */ PageHeaderComponent.prototype.affix; /** * @type {?} * @private */ PageHeaderComponent.prototype._menus; /** @type {?} */ PageHeaderComponent.prototype._titleVal; /** @type {?} */ PageHeaderComponent.prototype.paths; /** @type {?} */ PageHeaderComponent.prototype._title; /** @type {?} */ PageHeaderComponent.prototype._titleTpl; /** @type {?} */ PageHeaderComponent.prototype.loading; /** @type {?} */ PageHeaderComponent.prototype.wide; /** @type {?} */ PageHeaderComponent.prototype.home; /** @type {?} */ PageHeaderComponent.prototype.homeLink; /** @type {?} */ PageHeaderComponent.prototype.homeI18n; /** @type {?} */ PageHeaderComponent.prototype.autoBreadcrumb; /** @type {?} */ PageHeaderComponent.prototype.autoTitle; /** @type {?} */ PageHeaderComponent.prototype.syncTitle; /** @type {?} */ PageHeaderComponent.prototype.fixed; /** @type {?} */ PageHeaderComponent.prototype.fixedOffsetTop; /** @type {?} */ PageHeaderComponent.prototype.breadcrumb; /** @type {?} */ PageHeaderComponent.prototype.recursiveBreadcrumb; /** @type {?} */ PageHeaderComponent.prototype.logo; /** @type {?} */ PageHeaderComponent.prototype.action; /** @type {?} */ PageHeaderComponent.prototype.content; /** @type {?} */ PageHeaderComponent.prototype.extra; /** @type {?} */ PageHeaderComponent.prototype.tab; /** * @type {?} * @private */ PageHeaderComponent.prototype.renderer; /** * @type {?} * @private */ PageHeaderComponent.prototype.router; /** * @type {?} * @private */ PageHeaderComponent.prototype.menuSrv; /** * @type {?} * @private */ PageHeaderComponent.prototype.i18nSrv; /** * @type {?} * @private */ PageHeaderComponent.prototype.titleSrv; /** * @type {?} * @private */ PageHeaderComponent.prototype.reuseSrv; /** * @type {?} * @private */ PageHeaderComponent.prototype.cdr; } /** * @fileoverview added by tsickle * Generated from: page-header.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var COMPONENTS = [PageHeaderComponent]; var PageHeaderModule = /** @class */ (function () { function PageHeaderModule() { } PageHeaderModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, RouterModule, ObserversModule, LxlibUtilModule, NzAffixModule, NzSkeletonModule, NzBreadCrumbModule], declarations: __spread(COMPONENTS), exports: __spread(COMPONENTS), },] } ]; return PageHeaderModule; }()); /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: pageHeader.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { PageHeaderComponent, PageHeaderConfig, PageHeaderModule }; //# sourceMappingURL=pageHeader.js.map