UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

23 lines (21 loc) 11.2 kB
/** * @license ohayojp(cipchk@qq.com) v1.0.0 * (c) 2020 cipchk https://ohayojp.com/ * License: MIT */ !function (e, t) { "object" == typeof exports && "undefined" != typeof module ? t(exports, require("@angular/cdk/platform"), require("@angular/core"), require("@angular/router"), require("@ohayojp.com/components/reuse-tab"), require("@ohayojp.com/theme"), require("@ohayojp.com/util"), require("rxjs"), require("rxjs/operators"), require("@angular/cdk/observers"), require("@angular/common"), require("ng-zorro-antd/affix"), require("ng-zorro-antd/breadcrumb"), require("ng-zorro-antd/skeleton")) : "function" == typeof define && define.amd ? define("@ohayojp.com/components/page-header", ["exports", "@angular/cdk/platform", "@angular/core", "@angular/router", "@ohayojp.com/components/reuse-tab", "@ohayojp.com/theme", "@ohayojp.com/util", "rxjs", "rxjs/operators", "@angular/cdk/observers", "@angular/common", "ng-zorro-antd/affix", "ng-zorro-antd/breadcrumb", "ng-zorro-antd/skeleton"], t) : t(((e = "undefined" != typeof globalThis ? globalThis : e || self).ohayo = e.ohayo || {}, e.ohayo.components = e.ohayo.components || {}, e.ohayo.components["page-header"] = {}), e.ng.cdk.platform, e.ng.core, e.ng.router, e.ohayo.components["reuse-tab"], e.ohayo.theme, e.ohayo.util, e.rxjs, e.rxjs.operators, e.ng.cdk.observers, e.ng.common, e["ng-zorro-antd/affix"], e["ng-zorro-antd/breadcrumb"], e["ng-zorro-antd/skeleton"]) }(this, (function (e, t, n, r, i, o, a, s, l, p, u, c, d, h) { "use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function f(e, t, n, r) { var i, o = arguments.length, a = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, r); else for (var s = e.length - 1; s >= 0; s--)(i = e[s]) && (a = (o < 3 ? i(a) : o > 3 ? i(t, n, a) : i(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) } Object.create; function y(e, t) { var n = "function" == typeof Symbol && e[Symbol.iterator]; if (!n) return e; var r, i, o = n.call(e), a = []; try { for (; (void 0 === t || t-- > 0) && !(r = o.next()).done;)a.push(r.value) } catch (e) { i = { error: e } } finally { try { r && !r.done && (n = o.return) && n.call(o) } finally { if (i) throw i.error } } return a } function m() { for (var e = [], t = 0; t < arguments.length; t++)e = e.concat(y(arguments[t])); return e } Object.create; var v = function () { function e(e, t, n, i, o, a, p, u, c, d) { var h = this; this.renderer = t, this.router = n, this.menuSrv = i, this.i18nSrv = o, this.titleSrv = a, this.reuseSrv = p, this.cdr = u, this.inited = !1, this.unsubscribe$ = new s.Subject, this.isBrowser = !0, this._titleVal = "", this.paths = [], this.loading = !1, this.wide = !1, this.isBrowser = d.isBrowser, c.attach(this, "pageHeader", { home: "首页", homeLink: "/", autoBreadcrumb: !0, recursiveBreadcrumb: !1, autoTitle: !0, syncTitle: !0, fixed: !1, fixedOffsetTop: 64 }), e.notify.pipe(l.takeUntil(this.unsubscribe$), l.filter((function (e) { return h.affix && "layout" === e.type && "collapsed" === e.name }))).subscribe((function () { return h.affix.updatePosition({}) })), s.merge(i.change.pipe(l.filter((function () { return h.inited }))), n.events.pipe(l.filter((function (e) { return e instanceof r.NavigationEnd }))), o.change).pipe(l.takeUntil(this.unsubscribe$)).subscribe((function () { return h.refresh() })) } return Object.defineProperty(e.prototype, "menus", { get: function () { return this.menuSrv.getPathByUrl(this.router.url, this.recursiveBreadcrumb) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "title", { set: function (e) { e instanceof n.TemplateRef ? (this._title = null, this._titleTpl = e, this._titleVal = "") : (this._title = e, this._titleVal = this._title) }, enumerable: !1, 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) this.paths = []; else { var t = []; this.menus.forEach((function (n) { if (void 0 === n.hideInBreadcrumb || !n.hideInBreadcrumb) { var r = n.text; n.i18n && e.i18nSrv && (r = e.i18nSrv.fanyi(n.i18n)), t.push({ title: r, 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 } }, 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.inited && this.reuseSrv && (this.reuseSrv.title = this._titleVal)), this }, e.prototype.checkContent = function () { a.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 }(); v.decorators = [{ type: n.Component, args: [{ selector: "page-header", exportAs: "pageHeader", template: '<nz-affix #affix *ngIf="isBrowser && 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" [nzTitle]="false" [nzActive]="true" [nzParagraph]="{ rows: 3 }" [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: n.ChangeDetectionStrategy.OnPush, encapsulation: n.ViewEncapsulation.None }] }], v.ctorParameters = function () { return [{ type: o.SettingsService }, { type: n.Renderer2 }, { type: r.Router }, { type: o.MenuService }, { type: void 0, decorators: [{ type: n.Optional }, { type: n.Inject, args: [o.OHAYO_I18N_TOKEN] }] }, { type: o.TitleService, decorators: [{ type: n.Optional }, { type: n.Inject, args: [o.TitleService] }] }, { type: i.ReuseTabService, decorators: [{ type: n.Optional }, { type: n.Inject, args: [i.ReuseTabService] }] }, { type: n.ChangeDetectorRef }, { type: a.OhayoConfigService }, { type: t.Platform }] }, v.propDecorators = { conTpl: [{ type: n.ViewChild, args: ["conTpl", { static: !1 }] }], affix: [{ type: n.ViewChild, args: ["affix", { static: !1 }] }], title: [{ type: n.Input }], loading: [{ type: n.Input }], wide: [{ type: n.Input }], home: [{ type: n.Input }], homeLink: [{ type: n.Input }], homeI18n: [{ type: n.Input }], autoBreadcrumb: [{ type: n.Input }], autoTitle: [{ type: n.Input }], syncTitle: [{ type: n.Input }], fixed: [{ type: n.Input }], fixedOffsetTop: [{ type: n.Input }], breadcrumb: [{ type: n.Input }], recursiveBreadcrumb: [{ type: n.Input }], logo: [{ type: n.Input }], action: [{ type: n.Input }], content: [{ type: n.Input }], extra: [{ type: n.Input }], tab: [{ type: n.Input }] }, f([a.InputBoolean(), g("design:type", Object)], v.prototype, "loading", void 0), f([a.InputBoolean(), g("design:type", Object)], v.prototype, "wide", void 0), f([a.InputBoolean(), g("design:type", Boolean)], v.prototype, "autoBreadcrumb", void 0), f([a.InputBoolean(), g("design:type", Boolean)], v.prototype, "autoTitle", void 0), f([a.InputBoolean(), g("design:type", Boolean)], v.prototype, "syncTitle", void 0), f([a.InputBoolean(), g("design:type", Boolean)], v.prototype, "fixed", void 0), f([a.InputNumber(), g("design:type", Number)], v.prototype, "fixedOffsetTop", void 0), f([a.InputBoolean(), g("design:type", Boolean)], v.prototype, "recursiveBreadcrumb", void 0); var b = [v], I = function () { }; I.decorators = [{ type: n.NgModule, args: [{ imports: [u.CommonModule, r.RouterModule, p.ObserversModule, a.OhayoUtilModule, c.NzAffixModule, h.NzSkeletonModule, d.NzBreadCrumbModule], declarations: m(b), exports: m(b) }] }], e.PageHeaderComponent = v, e.PageHeaderModule = I, Object.defineProperty(e, "__esModule", { value: !0 }) })); //# sourceMappingURL=pageHeader.umd.min.js.map